[Chicago] create all classes

Lukasz Szybalski szybalski at gmail.com
Fri Feb 1 17:26:58 CET 2008


Hello,
I just converted big txt file definition to classes in .py file.

There are around 30 classes in the file. How can I iterate through
that file and initiate each class to some object in a list?

---blocks.py

class MSG_CTRL_BLK(object):
    def __init__(self):
        self.block='025A'
        self.GMSLOC=Element(self.block,'GLOC','MESSAGE HEADER','AN',26, 1)

so instead of typing :
a=MSG_CTRL_BLK()
....
...
30 times
....

I want:
Outside of the file I would like to :
import blocks
myblocks=[]
for i in blocks.xx???Xx:
    myblocks.append( i() )

what would be the function to get me list of classes?
How can I iterate and create them on a fly.

Lucas


More information about the Chicago mailing list