Create object name from string value?

Gnarlodious gnarlodious at
Fri Jan 22 23:00:33 CET 2010

On Jan 21, 9:21 am, Dave Angel wrote:

> Put it inside a dummy class, as follows:

This has been very educational, thank you for all the suggestions.
Here is the resulting code:

class Property: pass # example of a dummy class
Plist = Property() # create a Plist object from the dummy class

# accumulate dictionary attributes based on every plist file

for file in range(len(plistFiles)):
	setattr(Plist, name, Dict(plistFiles[file]).Config) # load the Plist
object with the dictionary

This is a vast improvement over my previous system. Now I can call any
plist item from anywhere on my website:


where "Site.plist" is the name of the Plist file. This is such an
elegant system I'm surprised it is not implemented as part of Python.

-- Gnarlie

More information about the Python-list mailing list