[Python-Dev] 'import as' (original) (raw)
Thomas Wouters thomas@xs4all.net
Thu, 17 Aug 2000 23:38:21 +0200
- Previous message: [Python-Dev] 'import as'
- Next message: [Python-Dev] 'import as'
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Aug 17, 2000 at 11:19:42PM +0200, Thomas Wouters wrote:
This also means that a 'global' statement now has effect on objects 'imported from' a module, except those imported by '*'.
And while I was checking my documentation patches, I found this:
Names bound by \keyword{import} statements may not occur in \keyword{global} statements in the same scope. \stindex{global}
But there doesn't seem to be anything to prevent it ! On my RedHat supplied Python 1.5.2:
def test(): ... global sys ... import sys ... test() sys <module 'sys' (built-in)>
And on a few weeks old CVS Python:
def test(): ... global sys ... import sys ... test() sys <module 'sys' (built-in)>
Also, mixing 'global' and 'from-import' wasn't illegal, it was just ineffective. (That is, it didn't make the variable 'global', but it didn't raise an exception either!)
How about making 'from module import *' a special case in this regard, and letting 'global' operate fine on normal 'import' and 'from-import' statements ? I can definately see a use for it, anyway. Is this workable (and relevant) for JPython / #Py ?
-- Thomas Wouters <thomas@xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
- Previous message: [Python-Dev] 'import as'
- Next message: [Python-Dev] 'import as'
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]