Den 02-03-2016 kl. 09:32 skrev Salvatore DI DIO:
Hello,

I know Python does not have variables, but names.
Multiple names cant then be bound to the same objects.

So this behavior

b = 234
v = 234
b is v
True

according to the above that is ok



But where is the consistency ? if I try :

v = 890
w = 890
v is w
False

It is a little difficult to explain this behavior to a newcommer in Python

Can someone give me the right argument to expose ?

Regards


You may get an answer to your question here: http://stackoverflow.com/questions/2419701/python-object-identity-question

As I understand it, when you use 'is', you are comparing addresses to objects, not the values contained in the objects. Use '==' instead.

Take a look here as well: https://docs.python.org/3.5/reference/datamodel.html

--
Venlig hilsen / Best regards
Jesper K. Brogaard

(remove upper case letters in my e-mail address)
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to