List comprehension - NameError: name '_[1]' is not defined ?
mario ruggier
mario.ruggier at gmail.com
Thu Jan 15 11:09:53 EST 2009
The listcomps exploration above was primarily an attempt
(unsuccessful) to make this piece of code go a little faster:
s = " text %(item)s text "
acc = []
for value in iterator:
some_dict["item"] = value
acc.append(s % evaluator)
"".join(acc)
The item=value pair is essentially a loop variable, and the evaluator
(something like the gie instance above) uses it via the updated
some_dict.
Is there any way to express the above as a list comp or so? Any ideas
how it might be made to go faster?
m.
More information about the Python-list
mailing list