the address of list.append and list.append.__doc__

Steve Holden steve at holdenweb.com
Tue Sep 25 23:19:29 EDT 2007


HYRY wrote:
> I have the following questions, I am using Python 2.4.2
> 
>>>> a = [1,2,3]
>>>> id(a.append)
> 19167152           #1
>>>> id(list.append)
> 11306608           #1
> 
> 1. the address of a.append and list.append is different, can I get the
> address of list.append from a.append?
> 
No. a.append is a "bound method" - a method that already has an 
associated instance, that will be provided as the first argument to the 
method call. Bound methods are created "on the fly".

> 
>>>> id(a.append.__doc__)
> 19162720
>>>> id(a.append.__doc__)
> 19162336
>>>> id(a.append.__doc__)
> 19162592
>>>> id(a.append.__doc__)
> 19162720
>>>> id(list.append.__doc__)
> 19162336
>>>> id(list.append.__doc__)
> 19162720
>>>> id(list.append.__doc__)
> 19162592
>>>> id(list.append.__doc__)
> 19162336
> 2. why the address of a.append.__doc__ and list.append.__doc__ change,
> this means __doc__ is not a normal string, but something return a
> string.
> Don't know. WJFFM on 2.5.1:

 >>> id(list.append.__doc__)
2146574752
 >>> id(list.append.__doc__)
2146574752
 >>> id(list.append.__doc__)
2146574752
 >>> id(list.append.__doc__)
2146574752
 >>>

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline




More information about the Python-list mailing list