On 11/13/2011 08:06 AM, lina wrote:
<SNIP>
Finally, if I am not wrong again, I feel I am kinda of starting
figuring out what's going on. Why it's None.

The main mistake here I use result = result.append(something)
the "="

I checked the print(id(result)) and print(id(result.append()),

For the NoneType they shared the same id 8823392 in my laptop. is it
temporary address?

None is a unique object, deliberately. No matter how many times people create None, it'll always be the same object. So
    a= None
    b = x.append(y)
    a is b           #(true)
    id(a) == id(b)        #(true)

Similarly  True and False are unique objects.

Other objects which are equal to each other may or may not have the same ID; you should not count on it. For example,
    x = 45+3
    y = 6*8

Checking (x==y) is true, of course. But checking (x is y) is indeterminate. It may be true for the first ten tests you do, and false next time

--

DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to