Method / Functions - What are the differences?

Michael Rudolf spamfresser at ch3ka.de
Sun Feb 28 11:39:03 EST 2010


Am 28.02.2010 15:08, schrieb Alf P. Steinbach:
>  >>> "Hello".upper
> <built-in method upper of str object at 0x00BA16E0>
>  >>> f = "Hello".upper
>  >>> f
> <built-in method upper of str object at 0x00BA16E0>
>  >>> f()
>    'HELLO'
>  >>>
>  >>>
>  >>>
>  >>> f.__self__
>    'Hello'

Holy hand grenade.
You have no Idea how enlightened I feel right now :D

Thank you, "bound method" was the term I forgot and your example... 
...totally revealed the internals behind this to me. Especially the last 
line I quoted.
I mean, I always knew *that* this works, but I never knew *why*.

Regards,
Michael



More information about the Python-list mailing list