Steve Holden wrote:
Nick Coghlan wrote:
z = [newval(i) for i in range(10)] using:
    def newval(x):
        if x % 2:
            return x - 2
        else:
            return x + 2

Just some more mental twiddling relating to the thread on statement local namespaces.

I presume the point of this is to avoid polluting the local namespace with "newval". I further presume you also have plans to do something about "i"? ;-)

Well, while I'm not at all a fan of the "using" syntax, getting rid of 'i' is simple:


z = list(newval(i) for i in range(10))

=)

Steve
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to