Proposal: Package aliases

Leandro Lucarella llucax at gmail.com
Thu May 15 13:49:44 PDT 2008


Steven Schveighoffer, el 15 de mayo a las 10:55 me escribiste:
> I admit, after writing all this, it does seem unlikely that you would ever 
> need to use the import foo : bar = baz.

You sometimes do. I ran to that recently using Python, I had a module tipc
imported:

import tipc

And then I needed some class named tipc in another module (called
comm.msg), so this is not a solution:

import  tipc
from comm.msg import tipc

Solutions:

import tipc
from comm.msg import tipc as tipcmsg
# use tipc and tipcmsg

Or:

import tipc
import comm.msg as msg
# use tipc and msg.tipc
(this is what Bill Baxter proposed for D, I think)

Or:

import tipc
import comm.msg
# use tipc and comm.msg.tipc (which can be too long if typed too often)


-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Did you see the frightened ones?
Did you hear the falling bombs?
Did you ever wonder why we had to run for shelter when the promise of a
brave new world unfurled beneath a clear blue sky?



More information about the Digitalmars-d mailing list