nested scopes
Tim Peters
tim.one at home.com
Sat Feb 3 14:57:50 EST 2001
More information about the Python-list mailing list
Sat Feb 3 14:57:50 EST 2001
- Previous message (by thread): nested scopes
- Next message (by thread): nested scopes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Tim] > ... > The determination of which names are local is still done at > compile-time in the presence of "import *" and "exec", but then > the results can't be trusted, and the compiler generates > different code that does all sorts of crap under the covers to > give "the expected" results -- most of the time. .... [Rainer Deyke] > "Most of the time" is significant here. I used to lose about 100 hairs a day. Now I think it's closer to 101. Much more significant to me <wink>. > There are at least two inconsistencies in functions with 'import *' > as of 2.0. Can you say "source of subtle bugs"? In this case, no. Yes, "import *" is a notorious source of subtle bugs, but all of them reported in real life are due to its advertised behavior (like "hey, 'open()' is broken!", "works for me", "no, it's broken", "what did you change?", "nothing!", "did it used to work?", "well, yes, but then it broke for no reason at all!", "and you changed nothing", "well, nothing relevant -- it just broke!", "so you did change something -- what (exactly) did you change?", "I added a global counter, so maybe the compiler generates bad code now ... and, OK, sure, I added 'from os import *'", ... and that one is so frequent the replybots automatically respond "from os import *" whenever somebody complains "hey, 'open()' is broken!" now). I posted some cases after the 0.9.9 release that showed endcase differences in "import *" and "exec" semantics due to the then-new local variable optimization. All of them were contrived. Guido didn't care; neither did I. In the approximately seven years since then, to the best of my knowledge no bug report on "import *" has ever been filed, and perhaps two were filed on "exec" but in non-contrived cases that were clearly broken. Nevertheless, if you fear the import* "bugs" *you* contrived, SourceForge is open 24 hours a day for patches <wink>. never-use-import-*-myself-except-in-an-interactive-shell-ly y'rs - tim
- Previous message (by thread): nested scopes
- Next message (by thread): nested scopes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list