Grant Edwards wrote:
> On 2012-10-09, Peter Otten <__pete...@web.de> wrote:
>
>> Welcome to python -- this is a trap every newbie falls into ;)
>>
>> Seriously, you shouldn't use the main script as a library;
>
> There must be something wrong with me. It never even occurred to me
> to try to im
On 10/09/2012 11:36 AM, Michele Simionato wrote:
> On Tuesday, October 9, 2012 5:24:17 PM UTC+2, Peter Otten wrote:
>> Seriously, you shouldn't use the main script as a library; it is put into
>>
>> the sys.modules cache under the "__main__" key. Subsequent imports under its
>>
>> real name will
On 2012-10-09, Peter Otten <__pete...@web.de> wrote:
> Welcome to python -- this is a trap every newbie falls into ;)
>
> Seriously, you shouldn't use the main script as a library;
There must be something wrong with me. It never even occurred to me
to try to import a file from within that same f
On Tuesday, October 9, 2012 5:24:17 PM UTC+2, Peter Otten wrote:
> Seriously, you shouldn't use the main script as a library; it is put into
>
> the sys.modules cache under the "__main__" key. Subsequent imports under its
>
> real name will not find that name in the cache and import another ins
Michele Simionato wrote:
> I have the following module implementing a registry of functions with a
> decorator:
>
> $ cat x.py
> registry = {} # global dictionary
>
> def dec(func):
> registry[func.__name__] = func
> print registry, id(registry)
> return func
>
> if __name__ == '__m
I have the following module implementing a registry of functions with a
decorator:
$ cat x.py
registry = {} # global dictionary
def dec(func):
registry[func.__name__] = func
print registry, id(registry)
return func
if __name__ == '__main__':
import xlib
print registry, id(re