class Meta:
def __init__(self,a,b):
exec "self.%s={}"%(a)
exec "self.%s={}"%(b)
a = Meta("x","y")
print "a.x = ",a.x
print "a.y = ",a.y
#What I think you should do :
class MetaMadeInPython:
def __init__(self,a,b):
self._data = {}
self._data[a] = {}
self._data[b] = {}
def __getitem__(self,index):
return self._data[index]
b = MetaMadeInPython("x","y")
print "b.x = ", b["x"]
print "b.y = ", b["y"]
otherwise a = Foo(school,children) will not work ! (and yes, there's no [new] operator in python to instanciate object !
You will have to call it like this :
a = Foo ("school","children")
See snippet to an example, but it's ugly. You should consider using dictionnaries !
Open in new window