Namespace Problem with global declaration in module

spex66 at my-deja.com spex66 at my-deja.com
Fri Apr 28 18:22:36 CEST 2000


In article <1255280660-66425116 at hypernet.com>,
  gmcm at hypernet.com wrote:
[snip]
> > I see the point, but I like the from statement :)
>
> Tough :-). import * is mostly a shortcut for interactive work. Look
at the
> top of Tkinter.py to see what a module needs to do to make import *
> safe.
>
> > Is it a bug?
>
> No.
>
> > It's not the way I expected this code to work... and
> > I cannot find a hook in the documentation that explicit explained
> > this misbehaviour.
>
> It's there, in 6.11 of the Language Ref:
>
> The from form does not bind the module name: it goes through the
> list of identifiers, looks each one of them up in the module found in
> step (1), and binds the name in the local namespace to the object
> thus found. If a name is not found, ImportError is raised. If the
list
> of identifiers is replaced by a star ("*"), all names defined in the
> module are bound, except those beginning with an underscore ("_").
>
> No, the implications of that statement are not immediately obvious.
>
> > Any idea for a workaround (I need the from-statement for further
> > code readability)?
>
> No, you want it for type-ability. Come back to it in a few months and
> you'll wish you'd spelled out where all those names came from.
Not only, it is for automated code-generation *and* simple interactive
work :-)

I've found a solution working for me, I posted it in my other actual
thread "How can I get the name of an object???" 28/4/00 17:20

probably it's getting a little bit clearer why I'm riding that horse :)

thanks for your input
Peter
(=PA=)


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list