lars111 lars111 - 1 year ago 121
Python Question

Python class input argument

I am new to OOP. My idea was to implement the following class:

class name(object, name):
def __init__(self, name):
print name

Then the idea was to create two instances of that class:

person1 = name("jean")
person2 = name("dean")

I know, that is not possible, but how can I pass an input-argument into an instance of a class?

Answer Source
>>> class name(object):
...     def __init__(self, name):
... = name
>>> person1 = name("jean")
>>> person2 = name("dean")

Is this what you are looking for?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download