Namespace Problem with global declaration in module

spex66 at spex66 at
Thu Apr 27 11:25:42 CEST 2000

hmm, deja is not so fast as my newsreader :), so here is a reply of
Gordons message

>spex66 at wrote:
>> Hi,
>> it seemed very simple but don't worked like expected:
>> #FILE:
>> dd = None #INIT a shadow instance for automated access
>> class zz:
>>     #ONLY one class will be instantiated
>>     def __init__(self):
>> = 'hallo'
>>         global dd
>>         dd = self
>> >>> from test import *
>There's your problem. "from test import *" copies names from
>test to your namespace. Now dd is another name for None.
>yy() affects the dd in test's namespace, not yours.
>- Gordon

I see the point, but I like the from statement :)
Is it a bug? It's not the way I expected this code to work... and I
cannot find a hook in the documentation that explicit explained this

Any idea for a workaround (I need the from-statement for further code


>> >>> yy = zz()
>> >>>
>>     ...
>>     AttributeError
>>     ...

Sent via
Before you buy.

More information about the Python-list mailing list