python examples with __init__
Example 1: __init__ python
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
p1 = Person("John", 36) // Object definition
print(p1.name)
print(p1.age)
Example 2: __init__ python
class A(object):
def __init__(self):
self.x = 'Hello'
def method_a(self, foo):
print self.x + ' ' + foo