In article <00a7037c$0$15659$c3e8...@news.astraweb.com>, Steven D'Aprano <st...@remove-this-cybersource.com.au> wrote: >> 2009/12/7 vsoler <vicente.so...@gmail.com>: >>> >>> 3. Mark says: The from statement is really an assignment to names in >>> the importer's scope--a name-copy operation, not a name aliasing. Â I >>> don't fully understand what he means. Could anybody explain? > >I'm not sure what Mark means by that either. It certainly isn't a copy >operation, it doesn't duplicate the object you imported. I don't know >what he means by aliasing, but if he means what I mean by aliasing, then >I'd say the from statement *is* an aliasing operation: it creates a new >name that refers to an existing object found by name. > >from module import name > >is roughly equivalent to: > >import module >name = module.name >del module
The reason why Mark made his comment (although I think it needs some rephrasing): import module from module import name name = 'foo' print module.name is name (Of course this is all completely obvious to anyone who understands Python's name/binding semantics, but someone just learning about module imports is probably not in that category and needs some kind of warning about re-assigning names created by ``from ... import``.) -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ Looking back over the years, after I learned Python I realized that I never really had enjoyed programming before.
-- http://mail.python.org/mailman/listinfo/python-list