[Patches] [Patch #101215] extend 'import x as y' syntax to 'import x as y.z'

noreply@sourceforge.net noreply@sourceforge.net
Fri, 18 Aug 2000 04:08:41 -0700


Patch #101215 has been updated. 

Project: 
Category: core (C code)
Status: Open
Summary: extend 'import x as y' syntax to 'import x as y.z'

Follow-Ups:

Date: 2000-Aug-18 05:25
By: nowonder

Comment:
I've played a bit around with the new 'import x as y' syntax and found it would be useful to be able to assign to module/class members, too.

Example from BaseHTTPServer:
  import SOCKS; socket = SOCKS; del SOCKS
  from socket import getfqdn; socket.getfqdn = getfqdn; del getfqdn

could become:
  import SOCKS as socket # nothing new here
  from socket import getfqdn as socket.getfqdn # NEW!

Assigned to Thomas for review.
-------------------------------------------------------

Date: 2000-Aug-18 11:08
By: marangoz

Comment:
Before going too far with this, here's a strong -1 without even reviewing
the patch. Playing with namespaces other than the current one is a bad
idea.

+1 on import x as y. As long as you introduce a new binding in the
current namespace, being able to alter the original name for that binding
is nice.

-1 on import x as y.z, though, because you want to introduce a binding
in a namespace which you don't own (y's namespace). For that matter,
y must exist in the current namespace and allow bindings, which is not
granted at all. Overall, this sucks <wink>. Example:

>>> y = 1
>>> import sys as y.sys

Please reject this before I see another patch update, or I'll reject it on
the first update that'll hit my mailbox <wink>.
-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=101215&group_id=5470