Personal tools
You are here: Home Weblog Archive 2006 August 16 Creating arbitrary objects in the current module namespace
Document Actions
  • Send this page to somebody
  • Print this page
  • Add Bookmarklet

Creating arbitrary objects in the current module namespace

by tibi last modified 2006-08-17 05:40
Filed Under:

This short recipe will show how to create arbitrary named objects in the current module namespace. Either globals() or locals() can be used for the task, depending on the namespace where the variables have to be created (global or local).

>>> for i in range(10):
>>> globals()['test%s' % i] = i
>>> print test0
0
>>> print test1
1
Weblog
Atom
RDF
RSS 2.0
Powered by Quills
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: