Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Some jokes on Python :)
- class A():
- def foo(self):
- print 'foo'
- def bar(self):
- print 'bar'
- class B():
- def __init__(self, param = -1):
- self.x = param
- # Now have a nice day...
- a1 = A()
- a2 = A()
- a1.foo(), a2.foo()
- A.bar = lambda: 1 # function that returns 1 - replaced for class A. Will not touch a1 and a2!
- a3 = A()
- # Please enjoy yourselves...
- print dir(a1)
- print dir(a2)
- print dir(a3)
- print dir(A)
- ############################################################
- b1 = B(1)
- # ...
- del B.__init__ # Remove constructor from class
- print dir(b1)
- print dir(B)
- # Now try to create object :)
- try:
- b2 = B(2)
- except:
- print ':('
- b3 = B() # Though the default constructor is possible way to...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement