python - Filter object has no attribute pop -
colorramps = re.split("#ramp\[([0-9a-fa-f]{6})\](.+?)#rampend\[([0-9a-fa-f]{6})\]", message) colorramps.reverse() if len(colorramps) > 1: starttext = colorramps.pop() starttext = starttext.replace("$message", getsavestring(text)) starttext = starttext.replace("$playername", getsavestring(username), 1) complete = [starttext] while len(colorramps): startcolor = getcolor(colorramps.pop()) colors = filter(none, re.split("#over\[([0-9a-fa-f]{6})\]", colorramps.pop())) middletxt = colors.pop() endcolor = getcolor(colorramps.pop()) middletxt = middletxt.replace("$message", getsavestring(text)) middletxt = middletxt.replace("$playername", getsavestring(username), 1) middletxt = middletxt.decode("utf") if len(colors) > 0: colors = map(getcolor, colors) colors.append(endcolor) middletxt = rangeovercolors(middletxt, startcolor, colors) else: middletxt = getrangestring(middletxt, startcolor, endcolor) middletxt = middletxt.encode("utf") complete.append(middletxt) endtext = colorramps.pop() endtext = endtext.replace("$message", getsavestring(text)) endtext = endtext.replace("$playername", getsavestring(username), 1) complete.append(endtext) message = "".join(complete) else: message = message.replace("$message", getsavestring(text)) message = message.replace("$playername", getsavestring(username), 1) return message
hello guys! im getting in line 128, in replacecolorramps middletxt = colors.pop()
attributeerror: 'filter' object has no attribute 'pop'
i used code python 2.5 , im porting 3.4..
can me
are running in python 3?
in python 2.7 filter()
returned list
, has .pop()
function.
in python 3.x filter()
returns filter
iterable object not.
before can .pop()
filter
in python 3 need convert list. add e.g.
colors = list(colors)
after colors = filter(...)
line. in python 2.7 have no effect, code continue work there. see this question more information , these docs.
Comments
Post a Comment