Reputation: 4596
For example values from args
i can extract like this
globals().update(vars(args))
Is it possible automatically create same properties fro class? Something like this
class SomeClass():
def __init__(self, args):
globals().update(vars(args))
exit(self.location)
Upvotes: 0
Views: 40
Reputation: 1122582
I think you meant you want to update the attributes on the class; you can do so with:
class SomeClass():
def __init__(self, args):
vars(self).update(vars(args))
Demo:
>>> class Foo:
... def __init__(self):
... self.bar = 'baz'
...
>>> result = SomeClass(Foo())
>>> result.bar
'baz'
Upvotes: 1