Hi, Robert Bradshaw wrote: >>> >>> foo.py: >>> print __name__ >>> >>> But under Python it returns "foo", "__builtin__" when cython'ized. >>> >>> As the documentation specifies, this can be fixed by: >>> >>> foo.py: >>> global __name__ >>> print __name__ >>> >>> Then both return "foo". >> >> Ah, good catch. Cython (and, incidentally I) didn't know that >> __name__ is an already declared module-level variable, hence it >> looked it up as a builtin (and found it there, so no error). This is >> easily fixed by always having __name__ in the module namespace (what >> other magic variables are there?) > > $ touch foo.py > $ python2.5 -c 'import foo; print foo.__dict__.keys()' > ['__builtins__', '__name__', '__file__', '__doc__'] > > To clarify, other than these (thanks for the list Lisandro) the only > time this can cause issues is if one manually adds names to the > module externally, or if one uses "import *" to overwrite a builtin.
Do you plan to fix it (0.10.3 does not)? Cheers, Stephane _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
