Variable Substitution in commands or funtion names?

Terry Reedy tjreedy at home.com
Thu Jul 19 18:36:58 CEST 2001


> 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"]

If I understand correctly, try (not tested)

import cust
current = getattr(cust, CurCust)
print current['street']

etc

Terry J. Reedy






More information about the Python-list mailing list