Re: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python

2016-03-25 Thread Ethan Furman
On 03/25/2016 06:03 AM, Albert-Jan Roskam wrote: > Somebody wrote: >> Somebody else wrote: 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

Re: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python

2016-03-25 Thread Chris Angelico
On Sat, Mar 26, 2016 at 12:03 AM, Albert-Jan Roskam wrote: >> You should not bother with object identity for objects other than None. > > > A little late to the party, but: how about Ellipsis? Shouldn't "is" also be > used for that one? (It's rare, I know :)) Yes, and also True and False, if you

RE: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python

2016-03-25 Thread Albert-Jan Roskam
> To: python-list@python.org > From: __pete...@web.de > Subject: Effects of caching frequently used objects, was Re: Explaining > names vs variables in Python > Date: Wed, 2 Mar 2016 10:12:48 +0100 > > Salvatore DI DIO wrote: > > > Hello, > > > >

Re: Explaining names vs variables in Python

2016-03-03 Thread Ian Kelly
On Thu, Mar 3, 2016 at 10:03 AM, Rustom Mody wrote: > Is it so damn hard to be a bit honest and when asked about is in python to > reply: > > If you dont know what you are doing, dont use 'is' (None excepted) > If you know why are you asking? That seems like a rather unhelpful response. -- http

Re: Explaining names vs variables in Python

2016-03-03 Thread Rustom Mody
On Thursday, March 3, 2016 at 7:22:43 AM UTC+5:30, Steven D'Aprano wrote: > On Thu, 3 Mar 2016 05:12 am, Marko Rauhamaa wrote: > > > Steven D'Aprano : > > > >> In this case, "same object" carries the normal English meaning of > >> "same" and the normal computer science meaning of "object" in the

Re: Explaining names vs variables in Python

2016-03-03 Thread Mark Lawrence
On 03/03/2016 02:05, Steven D'Aprano wrote: On Thu, 3 Mar 2016 08:49 am, Mark Lawrence wrote: On 02/03/2016 17:23, Steven D'Aprano wrote: On Thu, 3 Mar 2016 01:11 am, Marko Rauhamaa wrote: What is missing is the rules that are obeyed by the "is" operator. I think what is actually missing i

Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
On Thu, 3 Mar 2016 08:49 am, Mark Lawrence wrote: > On 02/03/2016 17:23, Steven D'Aprano wrote: >> On Thu, 3 Mar 2016 01:11 am, Marko Rauhamaa wrote: >> >>> What is missing is the rules that are obeyed by the "is" operator. >> >> I think what is actually missing is some common bloody sense. The Py

Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
On Thu, 3 Mar 2016 05:12 am, Marko Rauhamaa wrote: > Steven D'Aprano : > >> In this case, "same object" carries the normal English meaning of >> "same" and the normal computer science meaning of "object" in the >> sense of "Object Oriented Programming". There's no mystery here, no >> circular def

Re: Explaining names vs variables in Python

2016-03-02 Thread Rustom Mody
On Thursday, March 3, 2016 at 3:22:42 AM UTC+5:30, Chris Angelico wrote: > On Thu, Mar 3, 2016 at 8:49 AM, Mark Lawrence wrote: > > Are we discussing UK (highly generalised), Geordie, Glaswegian, US, > > Canadian, South African, Australian, New Zealand, or some other form of > > English? > > Is t

Re: Explaining names vs variables in Python

2016-03-02 Thread Mark Lawrence
On 02/03/2016 21:52, Chris Angelico wrote: On Thu, Mar 3, 2016 at 8:49 AM, Mark Lawrence wrote: Are we discussing UK (highly generalised), Geordie, Glaswegian, US, Canadian, South African, Australian, New Zealand, or some other form of English? Is there any disagreement among them about the w

Re: Explaining names vs variables in Python

2016-03-02 Thread Chris Angelico
On Thu, Mar 3, 2016 at 8:49 AM, Mark Lawrence wrote: > Are we discussing UK (highly generalised), Geordie, Glaswegian, US, > Canadian, South African, Australian, New Zealand, or some other form of > English? Is there any disagreement among them about the word "same"? ChrisA -- https://mail.pyth

Re: Explaining names vs variables in Python

2016-03-02 Thread Mark Lawrence
On 02/03/2016 17:23, Steven D'Aprano wrote: On Thu, 3 Mar 2016 01:11 am, Marko Rauhamaa wrote: What is missing is the rules that are obeyed by the "is" operator. I think what is actually missing is some common bloody sense. The Python docs are written in English, and don't define *hundreds*,

Re: Explaining names vs variables in Python

2016-03-02 Thread Marko Rauhamaa
Steven D'Aprano : > In this case, "same object" carries the normal English meaning of > "same" and the normal computer science meaning of "object" in the > sense of "Object Oriented Programming". There's no mystery here, no > circular definition. I see three possible ways of defining "is" / objec

Re: Explaining names vs variables in Python

2016-03-02 Thread Ben Finney
Salvatore DI DIO writes: > I know Python does not have variables, but names. In addition to the other food answers in this thread, you will want to watch http://nedbatchelder.com/text/names.html> Ned Batchelder's presentation on “Facts and myths about Python names and values”. -- \“Me

Re: Explaining names vs variables in Python

2016-03-02 Thread Rustom Mody
On Wednesday, March 2, 2016 at 10:53:40 PM UTC+5:30, Steven D'Aprano wrote: > On Thu, 3 Mar 2016 01:11 am, Marko Rauhamaa wrote: > > > What is missing is the rules that are obeyed by the "is" operator. > > I think what is actually missing is some common bloody sense. The Python > docs are written

Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
On Thu, 3 Mar 2016 01:11 am, Marko Rauhamaa wrote: > What is missing is the rules that are obeyed by the "is" operator. I think what is actually missing is some common bloody sense. The Python docs are written in English, and don't define *hundreds*, possible *thousands* of words because they are

Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
On Thu, 3 Mar 2016 12:48 am, Chris Angelico wrote: > On Thu, Mar 3, 2016 at 12:39 AM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> Python defines that every object has an identity, which can be >>> represented as an integer. Since this is an intrinsic part of the >>> object, no two distinct o

Re: Explaining names vs variables in Python

2016-03-02 Thread Jussi Piitulainen
Ian Kelly writes: > On Wed, Mar 2, 2016 at 2:35 AM, Jussi Piitulainen wrote: >> The following are too delicate for me. I suppose the answers could have >> been different, but I can't guess what mechanism actually leads to these >> results. Just idle curiosity on my part. >> > 890 is 890 >> Tru

Re: Explaining names vs variables in Python

2016-03-02 Thread Ian Kelly
On Wed, Mar 2, 2016 at 2:35 AM, Jussi Piitulainen wrote: > The following are too delicate for me. I suppose the answers could have > been different, but I can't guess what mechanism actually leads to these > results. Just idle curiosity on my part. > 890 is 890 > True id(890) == id(890)

Re: Explaining names vs variables in Python

2016-03-02 Thread Rustom Mody
On Wednesday, March 2, 2016 at 7:42:09 PM UTC+5:30, Marko Rauhamaa wrote: > Chris Angelico : > > > On Thu, Mar 3, 2016 at 12:39 AM, Marko Rauhamaa wrote: > >> Chris Angelico : > >> > >>> Python defines that every object has an identity, which can be > >>> represented as an integer. Since this is

Re: Explaining names vs variables in Python

2016-03-02 Thread Marko Rauhamaa
Chris Angelico : > On Thu, Mar 3, 2016 at 12:39 AM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> Python defines that every object has an identity, which can be >>> represented as an integer. Since this is an intrinsic part of the >>> object, no two distinct objects can truly have identical >>

Re: Explaining names vs variables in Python

2016-03-02 Thread Chris Angelico
On Thu, Mar 3, 2016 at 12:39 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> Python defines that every object has an identity, which can be >> represented as an integer. Since this is an intrinsic part of the >> object, no two distinct objects can truly have identical >> characteristics. Python'

Re: Explaining names vs variables in Python

2016-03-02 Thread Marko Rauhamaa
Chris Angelico : > Python defines that every object has an identity, which can be > represented as an integer. Since this is an intrinsic part of the > object, no two distinct objects can truly have identical > characteristics. Python's objects are like rifles - there are many > like it, but this

Re: Explaining names vs variables in Python

2016-03-02 Thread Jussi Piitulainen
Chris Angelico writes: > Python defines that every object has an identity, which can be > represented as an integer. Since this is an intrinsic part of the > object, no two distinct objects can truly have identical > characteristics. Python's objects are like rifles - there are many > like it, bu

Re: Explaining names vs variables in Python

2016-03-02 Thread Chris Angelico
On Wed, Mar 2, 2016 at 11:34 PM, Marko Rauhamaa wrote: > The ontological question is, can two *distinct* objects with *identical* > characteristics exist? > > The fermionic answer is, no. > > The bosonic answer is, sure. > > Set theory has fermionic ontology (it's called extensionality). > > Pytho

Re: Explaining names vs variables in Python

2016-03-02 Thread Marko Rauhamaa
Steven D'Aprano : > On Wed, 2 Mar 2016 08:03 pm, Jesper K Brogaard wrote: > >> As I understand it, when you use 'is', you are comparing addresses to >> objects, not the values contained in the objects. Use '==' instead. > > You should not think about addresses, because the location of objects > is

Re: Explaining names vs variables in Python

2016-03-02 Thread Salvatore DI DIO
Thank you very much ast and all of you. I better understant now Regards -- https://mail.python.org/mailman/listinfo/python-list

Re: Explaining names vs variables in Python

2016-03-02 Thread ast
"Salvatore DI DIO" a écrit dans le message de news:a894d5ed-d906-4ff7-a537-32bf0187e...@googlegroups.com... It is a little difficult to explain this behavior to a newcommer in Python Can someone give me the right argument to expose ? It is explained with many details here: http://blog.ler

Explaining names vs variables in Python (follow)

2016-03-02 Thread Salvatore DI DIO
Thank you very much all of you. I better understand now Regards -- https://mail.python.org/mailman/listinfo/python-list

Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
On Wed, 2 Mar 2016 08:03 pm, Jesper K Brogaard wrote: > As I understand it, when you use 'is', you are comparing addresses to > objects, not the values contained in the objects. Use '==' instead. You should not think about addresses, because the location of objects is not part of the language. It

Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
On Wed, 2 Mar 2016 07:32 pm, Salvatore DI DIO wrote: > Hello, > > I know Python does not have variables, but names. > Multiple names cant then be bound to the same objects. Multiple names CAN be bound to the same object: py> x = y = [] py> x is y True py> z = x py> y.append("Hello world!") py>

Re: Explaining names vs variables in Python

2016-03-02 Thread Jussi Piitulainen
Salvatore DI DIO writes: [- -] > But where is the consistency ? if I try : > v = 890 w = 890 v is w > False I think it goes as follows. Python keeps a cached pool of some numbers that may occur relatively often. When a numerical expression evaluates to a cached value, it returns

Effects of caching frequently used objects, was Re: Explaining names vs variables in Python

2016-03-02 Thread Peter Otten
Salvatore DI DIO wrote: > 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

Re: Explaining names vs variables in Python

2016-03-02 Thread Antoon Pardon
On 02/03/2016 09:32, Salvatore DI DIO wrote: > Hello, > > I know Python does not have variables, but names. > Multiple names cant then be bound to the same objects. > > So this behavior Python has variables. They are just not the kind of variables you find in C and variations but more like variab

Re: Explaining names vs variables in Python

2016-03-02 Thread Jesper K Brogaard
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 =

Explaining names vs variables in Python

2016-03-02 Thread 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