Import Question ..

Peter Otten __peter__ at web.de
Mon Jul 12 08:32:31 EDT 2004


Skulled2003 at netscape.net wrote:

> import def
> 
> def dosomething(something)
> 
>    if something == 'firstlist':
>       listdef = def.firstlistCommonPart
>    elif something == 'secondlist':
>       listdef = def.secondlistCommonPart
> 
> This is quite frustrating if i have lots of definitions. So is there a way
> where i could get something like:

Now 'def' is a _really_ bad name for a module - I'll use 'module' instead.

import module

def dosomething(something):
    listdef = getattr(module, something + "CommonPart")

Peter




More information about the Python-list mailing list