Hi,

This is my frist post here. I am learning Python and Qt and am trying to
understand a pecularity with object references. I think I get the integer
part, but for floating point it seems like the caching/interning process
works a little bit here and there:

1) Same object on command line
>>> a, b = 5.0, 5.0
>>> id(a), id(b)
(11140648, 11140648)

2) Different object on command line
>>> a = 5.0
>>> b = 5.0
>>> id(a), id(b)
(11140616, 11140600)

3) Same object in script
When running the last assignments for the float objects in a script (point
2) above, one line per assignment), it is cached again and the variables
refer to the same object. Why is it different on a command line and in a
script?

How can you know when you create a new object or not, are there any rules?

Thanks for a great forum.

Regards,
Bjorn
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to