On Sun, Jul 29, 2001 at 01:00:59PM -0400, Guido van Rossum wrote: > > (with future statement) > > >>> def spam(x): > > ... from stat import * > > ... def eggs(): > > ... print x > > ... > > File "<stdin>", line 2 > > SyntaxError: import * is not allowed in function 'spam' because it contains > > a nested function with free variables > Hm. I'm curious why it was not made a warning without a nested > function. Perhaps because too much 3rd party code would trigger the > warning? Yes. > (I have a feeling that lots of amateur programmers are a lot > fonder of import * than they should be :-( ). Oh yeah. If ActiveState's mailinglist statistics were extended to show howmany of my posts preach against using 'import *', I'd be top dog in the python-list stats :-) I also still owe Fred a tutorial chapter on why not to use import * :) > > >>> def spam(x,y): > > ... exec y > > ... def eggs(): > > ... print x > That one is just fine I think. Why is 'import *' inside a function fine, but a bare exec isn't ? Weren't you going to deprecate bare exec's altogether ? -- Thomas Wouters <thomas@xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4