Newbie question. Are those different objects ?

Terry Reedy tjreedy at udel.edu
Fri Dec 20 16:56:10 EST 2013


On 12/20/2013 10:16 AM, dec135 at msn.com wrote:
> y = raw_input('Enter a number:')
> print type y
> y = float(raw_input('Enter a number:'))
> print type y

I recommend starting with 3.3 unless your are forced to use 2.x.
I also recommend trying code before posting it.

> I'm assuming that y is an object.

The name 'y' is bound to an object. The second assignment rebinds 'y' to 
a different object.

> I'm also assuming that the second and the first y are different objects

It depends on whether by 'y' you mean the name, which remains the same, 
or the object it is bound to, which changes.


-- 
Terry Jan Reedy




More information about the Python-list mailing list