I have the following class:
class NewName:
def __init__(self):
self.Name = None
self.DecomposedAlias = OrderedDict([("Prefix", None),
("Measurement", None),
("Direction", None),
("Item", None),
("Location", None),
("Descriptor", None),
("Frame", None),
("RTorigin", None)])
self.Meaning = ""
self.SIUnit = OrderedDict([("ScaleFactor", None),
("Offset", None),
("A", None),
("cd", None),
("K", None),
("kg", None),
("m", None),
("mol", None),
("rad", None),
("s", None)])
self.NormalDisplayUnit = OrderedDict([("ScaleFactor", None),
("Offset", None),
("A", None),
("cd", None),
("K", None),
("kg", None),
("m", None),
("mol", None),
("rad", None),
("s", None)])
self.OrientationConvention = ""
self.ContactPerson = ""
self.Note = ""
self.SubType = None
self.RefersTo = []
If I instantiate a new object of this class I can obtain a dictionary like this:
mynewname = NewName()
mynewdict = mynewname.__dict__
What if I want mynewdict
to be ordered in the same way the attributes of NewName
were instantiated in its __init__
?
Doing some research I found this, but in my case I would just obtain ['__init__']
. Is there a way to point to the attributes inside the __init__
?
For completeness sake I should mention that I am using Python 3.4.