text_combined: anthony tolle pkfrwatpbgmailcom thu mar 6 2008 1159 pm guido van rossum wrote would mind giving executive summary argument doesnt require scanning 40 lines code let put way unbound methods gone good think would nice develop guidance checking signature callable objects enable decorators play nice otherespecially intend modify argument list example lets say two wrappers around two different method types like short pseudocode example promise class aobject wrapper2 wrapper1 staticmethod def smargs wrapper2 wrapper1 def imself args lets say purpose wrapper1 wrapper2 insert new argument argument list combination method binding type would work follows examples selfcallable returned __get__ method wrapped descriptor static method return selfcallablenewarg args kwargs instance method instance binding ie bound method return selfcallablenewarg args kwargs instance method class binding ie unbound method return selfcallableargs0 newarg args1 kwargs notice change necessary maintain consistency handling instance binding class binding instance binding ie bound method instance argument passed implicitlyas first argumentby wrapped callable thus wrapper must simulate class binding instance argument must passed explicitly wrapper1 know whether wrapping static method bound method unbound method well one way could examine type descriptor wrapping sees instance staticmethod process however wrapper2 doesnt luxury since knows wrapping instance wrapper1 way examine callable returned __get__ method wrapped descriptor things get interesting python 25 extremely easy callable im_self attribute static function callable im_self attribute im_self none unbound method im_self none bound method simple theres attribute signature simple easily emulated wrapper1s __get__ function thus wrapper2 would able make determination plus wrapper1 could even copy im_func attribute would possible follow chain wrappers way back original function python 30 breaks pattern unbound methods longer exist examining callable returned __get__ signature static method unbound method plain functions wrapper able determine modify arguments compromise 1 python 30 functions readonly __self__ attribute set none looks like unbound method signature wise 2 bound methods continue behave callable object __self__ attribute referencing instance object __func__ attribute referencing original function object 3 function decorated staticmethod __get__ method return callable object wraps function callable object __self__ attribute __func__ attribute referencing original function 4 convention callable wraps another callable copy __self__ attribute lack thereof __func__ attribute thus signature preserved chain thus signature callable tested follows hasattrobj __self__ obj__self__ none unbound method else bound method else static method note class methods always fall category bound method whether instance binding used need differentiate instance method class method __self__ object examined see class _______________________________________________ python3000 mailing list smsbmo9552pythonorg httpmailpythonorgmailmanlistinfopython3000 unsubscribe httpmailpythonorgmailmanoptionspython3000python300040tangomucom wed 06 aug 2008 001651 0500 python3000 case unbound methods