Variable Substitution in commands or funtion names?

hao-nghi.au at fr.thalesgroup.com hao-nghi.au at fr.thalesgroup.com
Thu Jul 19 11:01:50 EDT 2001


Hi fleet,

Just learn that when you write : from cust import CurCust
==> CurCust becomes local and you have to reference to it by :
print CurCust["street"]

regards,
Hao-Nghi Au
-----Original Message-----
From: fleet at teachout.org [mailto:fleet at teachout.org]
Sent: Thursday, July 19, 2001 2:26 PM
To: python list
Subject: Variable Substitution in commands or funtion names?



I think I may have gotten myself into a box.

I have a module "cust.py" that contains several dictionaries - each
references a different customer with address info, etc. such as:

smith={"busname":"Smitties", "street":"123 West Ave"}

Parsing the csv output of a spreadsheet allows me to assign "smith" to a
variable - CurCust.

Now I want to do something like:

from cust import CurCust

print cust.CurCust["street"]

Spent the evening trying to solve this (Learning Python, and Sam's Teach
Yourself Python) then tried the archives.  The little I found on "variable
substitution" almost seems to say "no way!" ???

(I know someone is going to suggest a database.  That's a little further
up the learning curve.  I can see it from here; but I'm not there yet.)

Thanks for any assistance,
					- fleet -



-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list