python - How can I allow one or more arguments for initializing a class? -
if want create class each instance has have @ least 1 arguments have more. if has none should raise exception. how can achieve this?
you write class this:
class myclass(object): def __init__(self, first, *rest): # args
this accepts first argument first
, additional arguments tuple, rest
.
Comments
Post a Comment