Import Question ..

Skulled2003 at netscape.net Skulled2003 at netscape.net
Mon Jul 12 08:15:11 EDT 2004


Hello,

   I have a question on import. I have a file which contains some assorted lists, and some other definitions. But all of the list names have a common part to it and a specific part in the beginning. For example:

# file containing definitions 'def.py'

firstlistCommonPart = []

secondlistCommonPart = []


Now what i want to do is:

# some other file 'some.py'

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:

def dosomething(something):

    str = something+CommonPart # something is passed as a string
    listdef = def.str

basically i am asking if i can pass the string value to get an attribute from the def file. I tried doing something like in the above case, but it returns and tells me def has no attribute str.

Any help would be much appreciated.

Thanks,
Vinod


__________________________________________________________________
Switch to Netscape Internet Service.
As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register

Netscape. Just the Net You Need.

New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at http://channels.netscape.com/ns/search/install.jsp



More information about the Python-list mailing list