Python: How can I call __Init__ call for two different argument methods?
2 answers
http://docs.python.org/tutorial/controlflow.html#arbitrary-argument-lists
and the section immediately preceding it,
http://docs.python.org/tutorial/controlflow.html#keyword-arguments
In your specific case, it might look something like this:
def __init__(*args, **kwargs):
if args:
d = args[0]
self.name = d['name']
self.type = d['type']
else:
self.name = kwargs['name']
self.type = kwargs['type']
+3
source to share