[Patches] [Patch #101234] Allow all assignment expressions after 'import something as'
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 20 Aug 2000 13:02:32 -0700
Patch #101234 has been updated.
Project:
Category: core (C code)
Status: Open
Summary: Allow all assignment expressions after 'import something as'
Follow-Ups:
Date: 2000-Aug-19 21:29
By: twouters
Comment:
This absurdly simple patch (4 lines changed in 2 files) turns 'import-as' and 'from-import-as' into true assignment expressions: the name given after 'as' can be any expression that is a valid l-value:
>>> from sys import version_info as (maj,min,pl,relnam,relno)
>>> maj,min,pl,relnam,relno
(2, 0, 0, 'beta', 1)
>>> x = {}
>>> import sys as x['sys']
>>> import os as x['os']
>>> x
{'os': <module 'os' from './Lib/os.pyc'>, 'sys': <module 'sys' (built-in)>}
>>> class X: pass
...
>>> x = X()
>>> import sys as x.sys
>>> import os as x.os
>>> import posixpath as x.posixpath
>>> x.sys, x.os, x.posixpath
(<module 'sys' (built-in)>, <module 'os' from './Lib/os.pyc'>, <module 'posixpath' from './Lib/posixpath.pyc'>)
This looks so natural, I would almost treat this as a bugfix instead of a new feature ;)
-------------------------------------------------------
Date: 2000-Aug-20 20:02
By: nowonder
Comment:
Looks fine. Works as I expect. Doesn't break old code. I hope Guido likes it (assigned to gvanrossum).
<MODE value="excitement"> Talk about beautiful! I *love* this patch -- feels so natural. It was just what I wanted to do. </MODE>
-------------------------------------------------------
-------------------------------------------------------
For more info, visit:
http://sourceforge.net/patch/?func=detailpatch&patch_id=101234&group_id=5470