classOldClass():def__init__(self):print('I am an old class')classNewClass(object):def__init__(self):print('I am a jazzy new class')old =OldClass()# Output: I am an old classnew =NewClass()# Output: I am a jazzy new class
classGetTest(object):def__init__(self):print('Greetings!!')defanother_method(self):print('I am another method which is not'' automatically called')a =GetTest()# Output: Greetings!!a.another_method()# Output: I am another method which is not automatically# called
classGetTest(object):def__init__(self,name):print('Greetings!! {0}'.format(name))defanother_method(self):print('I am another method which is not'' automatically called')a =GetTest('yasoob')# Output: Greetings!! yasoob# Try creating an instance without the name argumentsb =GetTest()Traceback (most recent call last): File "<stdin>", line 1,in<module>TypeError:__init__() takes exactly 2arguments (1 given)