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

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -