What is the name of the name space I am in?

Anthra Norell anthra.norell at bluewin.ch
Mon Jul 5 08:16:25 EDT 2010


Thomas Jollans wrote:
> On 07/05/2010 11:07 AM, Anthra Norell wrote:
>   
>> I try to use "new.new.classobj (name, baseclass, dict)" and have no clue
>> what the "dict" of the current name space is. I can name dicts of 
>> imported modules, because their name exists in the current name space.
>> If, for instance, I import a module "service" then that module's name
>> space would be "service.__dict__". But if I import * from service, then
>> I incorporate that name space into the current one and I cannot name it,
>> because the current module's name is not part of the module's own name
>> space. "dir (service)" is equivalent to "service.__dict__.keys ()" if
>> service is importet. "dir ()" is equivalent to "?.__dict__.keys ()"
>> where "?" is the name of the current module, itself not part of the
>> current module's name space. So the question mark stands for an implicit
>> name that can be neither named nor dropped. So my question is: how does
>> one name the dictionary of the name space one is in?
>>     
>
> either globals() or locals(), depending on what you mean.
>
>   
>> Frederic
>>
>>     

Thomas,
Thanks a million. Just the tip I needed.
Frederic




More information about the Python-list mailing list