[MERGE] Repository.iter_files_bytes()
John Arbash Meinel
john at arbash-meinel.com
Thu Mar 26 13:21:29 GMT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
...
>
> Andrew> Huh? It sounds like you're saying that code like:
>
> Andrew> # foo.py
> Andrew> x = 1
> Andrew> def func():
> Andrew> x = 2
> Andrew> func()
> Andrew> print x == 1
>
> Andrew> would print False, which is clearly not the case in
> Andrew> Python. Assignment in a function doesn't modify
> Andrew> globals unless there is a “global” declaration in
> Andrew> that function, or unless I'm missing some very nasty
> Andrew> magic.
>
> It seems it is nasty black magic indeed :)
>
> Good hunt :)
>
> Vincent
>
>
I'm pretty sure that the issue is that gettext sets the "_"
function/operator/variable in "__builtins__". The wanted to do that so
it would be available everywhere, without having to do "from gettext
import gettext as _" at the top of every module (bringing it into your
globals).
However, as a builtin, it then has a single binding, and assigning to it
*modifies the builtin*.
So try:
# foo.py
import __builtins__
__builtins__.x = 1
def func():
x = 2
func()
print x
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAknLgVkACgkQJdeBCYSNAANbGACdFDYumUEciJvahAD741+UHNdO
mpcAn3LSi2CKfxpqGDIiTkaLnMZCePFJ
=ejnN
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list