Pastebin
Paste #1969: python
< previous paste - next paste>
Pasted by chrivers
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class A(object): ... def a(self): ... print 42 ... >>> a = A() >>> a.a <bound method A.a of <__main__.A object at 0x7f7348182ad0>> >>> dir(a.a) ['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', '__format__', '__func__', '__get__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'im_class', 'im_func', 'im_self'] >>> type(a.a) <type 'instancemethod'> >>> def foo(self): ... print 41 ... >>> a.foo = foo >>> type(a.foo); type(a.foo); <type 'function'> <type 'function'> >>> a.foo() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: foo() takes exactly 1 argument (0 given) >>> a.foo(None) 41 >>> a.foo <function foo at 0x7f7348171320> >>>
New Paste
Go to most recent paste.