Create object name from string value?

Gnarlodious gnarlodious at
Thu Jan 21 05:36:33 CET 2010

On Jan 20, 8:31 pm, Ben Finney <ben+pyt... at> wrote:
> Since (I presume) you are a newcomer to Python, it's best to learn the
> common style <URL:>.
Thanks for that.

> This is almost certainly better done with a dictionary. Like so::
>     object_names = ['object1', 'object2', 'object3', 'object4']
>     objects = {}
>     for object_name in object_names:
>         objects[object_name] = Class()

And thanks for that too. I see it returns a list of objects, Python is
very cool.

-- Gnarlie

More information about the Python-list mailing list