Of course ... I'm not quite sure what you are asking ...
There is nothing wrong with what you do, but you can skip class initialization if you showed. Just do:
class type1(object):
data = 'foo 1'
class type2(object):
data = 'foo 2'
Regardless of whether this makes sense in the context of what you are doing, I have no idea ...
In this case, you can simply do
class Container(object):
pass
type1, type2 = Container(), Container()
type1.data = 'foo 1'
type2.data = 'foo 2'
Or any other number of similar things ... What do type1and type2represent?
source
share