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

Popular posts from this blog

command line - Use qwinsta in PowerShell ISE -

java - Incorrect order of records in M-M relationship in hibernate -

Python website log in: BIG-IP can not find session information in the request -