Your code defines sclass as class variable, and you're checking an instance variable tcl.sclass.arg. These are two different things; class variables and instance variables.
If you want to use the same object to every instance - use class variable.
If the object is unique to every instance - use instance variable.
Every instance has sclass:
class ClassElement(object):
def __init__(self, argA, argB, sclass):
self.argA = argA
self.argB = argB
self.sclass = Subclass(sclass)
All instances share single object (your code):
>>> ClassElement.sclass
<__main__.Subclass object at 0x02942BF0>
>>> ClassElement.sclass.arg
'sclass'
>>> tcl2 = ClassElement('argA', 'argB')
>>> id(tcl2.sclass)
43265008
>>> id(tcl.sclass)
43265008
Ok I think I understand now what you are looking for
class ClassElement(object):
sclass = None
def __init__(self, argA, argB, sclass):
self.argA = argA
self.argB = argB
ClassElement.sclass = Subclass(sclass)
This will update the class variable with every instance creation.
ClassElementhas no attributesclass