the demise of 'from foo import * and its implications?
Robin Becker
robin at jessikat.fsnet.co.uk
Sat Mar 3 04:34:42 EST 2001
In article <mailman.983582584.8198.python-list at python.org>, Tim Peters
<tim.one at home.com> writes
>[Robin Becker]
>> it's an ambitious act to suppose that the new complicated
>> __twilight_zone__ rules are better than the old simpler rules because of
>> some optimisation.
>
>The official rule was that import* at other than module scope has undefined
>behavior. Still is. The complication comes from spelling out the accidents
>of the 2.1 implementation that intersect with the accidents of the 2.0
>implementation, for the benefit of whatever users may have been violating the
>rules without realizing it.
>
>Would you prefer that we let you dope that out for yourself? I'd be
>delighted to stick to the official rule, not catering at *all* to code that
>ignored the Ref Man. Then we could replace the entire explanation with a
>one-line quote from the manual: "you cheated; you got caught; tough luck".
>
>couldn't-be-simpler-than-that!-ly y'rs - tim
>
>
my preference would be that statements legal in one context should be
legal in another where they make sense. I cannot see how using import *
or eval etc in nested scopes is somehow obviously bad or different from
the same usage in non-nested scopes. The fact that the prohibition comes
from making things easier for the compiler adds to my confusion.
I have no particular objection to being able to access variables in
intermediate scopes.
If we really want to improve visibility we could try to make
>>> def bingo(a):
... if a<=1: return 0
... return bingo(a-1)*a
...
work naively, but I'm fairly sure this will be rejected as unpythonic or
somesuch.
--
Robin Becker
More information about the Python-list
mailing list