On 01/12/2015 12:25 PM, John Ladasky wrote:
> d = {0:"a", 1:"b", 2:"c", 3:"d"}
> e = [d[x] for x in (0,2)]
>
> class Foo:
> f = {0:"a", 1:"b", 2:"c", 3:"d"}
> print(f)
> g = [f[x] for x in (0,2)]In Foo 'f' is part of an unnamed namespace; the list comp 'g' has its own namespace, effectively making be a nonlocal; class name lookup skips nonlocal namespaces. Workaround: use an actual for loop. -- ~Ethan~
signature.asc
Description: OpenPGP digital signature
-- https://mail.python.org/mailman/listinfo/python-list
