A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2000-August/008427.html below:

[Python-Dev] 'import as'

[Python-Dev] 'import as'Thomas Wouters thomas@xs4all.net
Thu, 17 Aug 2000 23:19:42 +0200
I have two remaining issues regarding the 'import as' statement, which I'm
just about ready to commit. The first one is documentation: I have
documentation patches, to the ref and the libdis sections, but I can't
really test them :P I *think* they are fine, though, and they aren't really
complicated. Should I upload a patch for them, so Fred or someone else can
look at them, or just check them in ?

The other issue is the change in semantics for 'from-import'. Currently,
'IMPORT_FROM' is a single operation that retrieves a name (possible '*')
from the module object at TOS, and stores it directly in the local
namespace. This is contrary to 'import <module>', which pushes it onto the
stack and uses a normal STORE operation to store it. It's also necessary for
'from ... import *', which can load any number of objects.

After the patch, 'IMPORT_FROM' is only used to load normal names, and a new
opcode, 'IMPORT_STAR' (with no argument) is used for 'from module import *'.
'IMPORT_FROM' pushes the result on the stack, instead of modifying the local
namespace directly, so that it's possible to store it to a different name.
This also means that a 'global' statement now has effect on objects
'imported from' a module, *except* those imported by '*'.

I don't think that's a big issue. 'global' is not that heavily used, and old
code mixing 'import from' and 'global' statements on the same identifier
would not have been doing what the programmer intended. However, if it *is*
a big issue, I can revert to an older version of the patch, that added a new
bytecode to handle 'from x import y as z', and leave the bytecode for the
currently valid cases unchanged. That would mean that only the '... as z'
would be effected by 'global' statements. 

-- 
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