You don't, really. You could mess around with a definition like
def __init__(self, *args):
then do lots of processing that checks the number of arguments, the type of the first argument, etc. Or, you can simply be explicit and define a separate constructor whose name describes exactly what it does. The class method can do some validation on the tuple before passing its contents to the default constructor.
class Employee:
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
@classmethod
def from_tuple(cls, t):
if len(t) != 3:
raise ValueError("Wrong number of items in the tuple")
return cls(*t)
data = ('John','Smith',3000)
Employee.from_tuple(data)
Of course, the simplicity of the class method's definition suggests that you don't need to go to this much trouble: if you know the tuple has the right number and kinds of values, just unpack data for use with the default constructor.
Employee(*data)
By "default constructor", I mean the method which Employee.__new__ resolves to. Employee.__init__ is technically an initializer, invoked when appropriate on an already constructed instance returned by __new__.
Employee(*data), unpacking the tuple to the individual parameters.Employee(data)you usedEmployee(*data), you could use the single, straight-forward constructor.