Re: An oddity in list comparison and element assignment

2006-06-05 Thread Alex Martelli
Slawomir Nowaczyk <[EMAIL PROTECTED]> wrote: > On Sat, 03 Jun 2006 17:03:00 -0700 > [EMAIL PROTECTED] (Alex Martelli) wrote: > > #> Terry Reedy <[EMAIL PROTECTED]> wrote: > #> > #> > Depends what one means by 'copy'. See below for your alternate wording. > #> > #> Please give me a reasonable d

Re: An oddity in list comparison and element assignment

2006-06-05 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Yes. You stated it quite precisely. I believe l1==l2 should always > return True and l1==l3 should always be False. (unless l3 is reassigned > as l3=l1). Your idea of a separate operator for 'all elements have > numerically equal values at the moment of comparision' is

Re: An oddity in list comparison and element assignment

2006-06-05 Thread Slawomir Nowaczyk
On Sat, 03 Jun 2006 17:03:00 -0700 [EMAIL PROTECTED] (Alex Martelli) wrote: #> Terry Reedy <[EMAIL PROTECTED]> wrote: #> #> > Depends what one means by 'copy'. See below for your alternate wording. #> #> Please give me a reasonable definition of the unadorned word "copy" #> which would make thi

Re: An oddity in list comparison and element assignment

2006-06-03 Thread Alex Martelli
Terry Reedy <[EMAIL PROTECTED]> wrote: > > it's EXACTLY the > > concatenation of three copies of that string -- no more, no less. > > Depends what one means by 'copy'. See below for your alternate wording. Please give me a reasonable definition of the unadorned word "copy" which would make this

Re: An oddity in list comparison and element assignment

2006-06-03 Thread Terry Reedy
"Alex Martelli" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Terry Reedy <[EMAIL PROTECTED]> wrote: > >> <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> > (As an aside, may I point out that Python In A Nutshell states on page >> > 46 "The result of S*n or n*S is

Re: An oddity in list comparison and element assignment

2006-06-03 Thread michael . f . ellis
Hey Alex, lighten up! Python is a programming language -- not your family, religion, or civil rights. Cheers, Mike Alex Martelli wrote: > <[EMAIL PROTECTED]> wrote: >... > > (As an aside, may I point out that Python In A Nutshell states on page > > 46 "The result of S*n or n*S is the concatena

Re: An oddity in list comparison and element assignment

2006-06-03 Thread anton . vredegoor
Alex Martelli wrote: > <[EMAIL PROTECTED]> wrote: >> Can somebody please shut down this bot? I think it's running out of > > Much as you might love for somebody to "shut me down", that > (unfortunately, no doubt, from your viewpoint) is quite unlikely to > happen. Although "making predictions

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > [snip] > > Can somebody please shut down this bot? I think it's running out of Much as you might love for somebody to "shut me down", that (unfortunately, no doubt, from your viewpoint) is quite unlikely to happen. Although "making predict

Re: An oddity in list comparison and element assignment

2006-06-02 Thread anton . vredegoor
Alex Martelli wrote: [snip] Can somebody please shut down this bot? I think it's running out of control. It seems to be unable to understand that "don't be evil" might be good when you're small (at least it's not very bad) but that it becomes distinctly evil when you're big. What is good when

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Alex Martelli
Terry Reedy <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > (As an aside, may I point out that Python In A Nutshell states on page > > 46 "The result of S*n or n*S is the concatenation of n copies of S". > > It would be more exact to say that S*n is

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > (As an aside, may I point out that Python In A Nutshell states on page > 46 "The result of S*n or n*S is the concatenation of n copies of S". It > might be well to put a warning in a future edition that this is not > strictly the case.) Can you give me an exampl

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > (As an aside, may I point out that Python In A Nutshell states on page > 46 "The result of S*n or n*S is the concatenation of n copies of S". It would be more exact to say that S*n is [] extended with S n times, which makes it clear

Re: An oddity in list comparison and element assignment

2006-06-02 Thread michael . f . ellis
Perhaps a little background to my original post will defuse some of the controversy. While working during an airline flight, I ran into an unexpected outcome from using the * replication operator to initialize an array of lists. When I modified a single element of the array an entire column chang

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Terry Hancock
Alex Martelli wrote: > to be called "identical" by ALL observers (because trying to > ascertain the differences, if any, would inevitably perturb the > systems irretrievably by Heisenberg's effect Not to detract from your point, but the "Heisenberg effect", if you mean the "Heisenberg uncertain

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Terry Hancock
Alex Martelli wrote: > Slawomir Nowaczyk <[EMAIL PROTECTED]> wrote: > > On Thu, 01 Jun 2006 13:40:34 -0700 [EMAIL PROTECTED] wrote: > > #> Scott David Daniels wrote: #> > Would you say that envelope > > containing five $100 bills is equal to #> > an envelope containing > > five $100 bills with dif

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Terry Reedy
"Aahz" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Except, of course, that BofA doesn't exist anymore. Oh, the *name* > does, but what's now called BofA is simply the current name of the bank > that acquired BofA. In Pythonese, they performed SomeBank.extend(BofA) BofA = Some

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Aahz
In article <[EMAIL PROTECTED]>, Alex Martelli <[EMAIL PROTECTED]> wrote: > >Just to share some tidbits (about which, as an Italian now living >between San Francisco and San Jose, I'm sort of proud of...!-)...: > >Bank of America is a private bank, founded in San Francisco more than >100 years ago b

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Slawomir Nowaczyk
On Thu, 01 Jun 2006 19:16:16 -0700 [EMAIL PROTECTED] (Alex Martelli) wrote: #> > What does "parallel mutations" mean? In particular, what should be the #> > results of each of the following three comparisons: #> > #> > x, y, z = [1],[1],[1] #> > a, b = [x,y], [y,z] #> > c, d = [[1],[1]], [[1],[1]

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Maric Michaud
Le Vendredi 02 Juin 2006 00:12, [EMAIL PROTECTED] a écrit : > I believe that 'is' tests equality of reference, such that > > >>> a = range(1,3) > >>> b = range(1,3) > >>> a is b > > False > > The 'is' operator tells you whether a and b refer to the same object. Yeah ! That's it. And you proposed a

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Alex Martelli
Slawomir Nowaczyk <[EMAIL PROTECTED]> wrote: > On Thu, 01 Jun 2006 15:12:23 -0700 > [EMAIL PROTECTED] wrote: > > #> I believe that 'is' tests equality of reference, such that > #> > #> >>> a = range(1,3) > #> >>> b = range(1,3) > #> >>> a is b > #> False > #> > #> The 'is' operator tells you wh

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Alex Martelli
Slawomir Nowaczyk <[EMAIL PROTECTED]> wrote: > On Thu, 01 Jun 2006 13:40:34 -0700 > [EMAIL PROTECTED] wrote: > > #> Scott David Daniels wrote: > #> > Would you say that envelope containing five $100 bills is equal to > #> > an envelope containing five $100 bills with different serial numbers? >

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > I agree with Alex that checking for this type of inequality is not a > trivial programming exercise. It requires (at least) a parallel I'm not asking for ANY programming: I'm asking for a *straightforward operational definition*. If the concept which you hanke

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > Hi Alex, > With all due respect to your well-deserved standing in the Python > community, I'm not convinced that equality shouldn't imply invariance > under identical operations. So, why aren't you satisfying my request? Provide a simple concrete definition of what y

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Slawomir Nowaczyk
On Thu, 01 Jun 2006 15:12:23 -0700 [EMAIL PROTECTED] wrote: #> I believe that 'is' tests equality of reference, such that #> #> >>> a = range(1,3) #> >>> b = range(1,3) #> >>> a is b #> False #> #> The 'is' operator tells you whether a and b refer to the same object. #> What I've been discussing

Re: An oddity in list comparison and element assignment

2006-06-01 Thread michael . f . ellis
I believe that 'is' tests equality of reference, such that >>> a = range(1,3) >>> b = range(1,3) >>> a is b False The 'is' operator tells you whether a and b refer to the same object. What I've been discussing is whether == should test for "structural" equality so that a and b remain equivalent u

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Slawomir Nowaczyk
On Thu, 01 Jun 2006 13:40:34 -0700 [EMAIL PROTECTED] wrote: #> Scott David Daniels wrote: #> > Would you say that envelope containing five $100 bills is equal to #> > an envelope containing five $100 bills with different serial numbers? #> Yes (unless I was testing the assertion that the second e

Re: An oddity in list comparison and element assignment

2006-06-01 Thread michael . f . ellis
Truthfully, I wouldn't mind it at all. In Python, I frequently write things like i == int(f) or vice versa just to avoid subtle bugs that sometimes creep in when later modifications to code change the original assumptions. When working in C, I always set the compiler for maximum warnings and d

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Maric Michaud
Le Jeudi 01 Juin 2006 18:00, [EMAIL PROTECTED] a écrit : > Perhaps the most fundamental notion is mathematics is that the left and > right sides of an equation remain identical after any operation applied > to both sides. IMHO, you are not aware that the '=' symbol of mathematics exists in python,

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Erik Max Francis
[EMAIL PROTECTED] wrote: > With all due respect to your well-deserved standing in the Python > community, I'm not convinced that equality shouldn't imply invariance > under identical operations. Doo you really want 2 == 2.0 to be False? -- Erik Max Francis && [EMAIL PROTECTED] && http

Re: An oddity in list comparison and element assignment

2006-06-01 Thread michael . f . ellis
Yes (unless I was testing the assertion that the second envelope did not contain counterfeits of the first) Scott David Daniels wrote: > Would you say that envelope containing five $100 bills is equal to > an envelope containing five $100 bills with different serial numbers? -- http://mail.pytho

Re: An oddity in list comparison and element assignment

2006-06-01 Thread michael . f . ellis
Considering the number of new programmers who get bit by automatic coercion, I wish Dennis Ritchie had made some different choices when he designed C. But then I doubt he ever dreamed it would become so wildly successful. Being a curmudgeon purist I'd actually prefer it if Python raised a TypeErr

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Jim Segrave
In article <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> wrote: >Yes. You stated it quite precisely. I believe l1==l2 should always >return True and l1==l3 should always be False. (unless l3 is reassigned >as l3=l1). Your idea of a separate operator for 'all elements have >numerically equal values at

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi Alex, > With all due respect to your well-deserved standing in the Python > community, I'm not convinced that equality shouldn't imply invariance > under identical operations. > > Perhaps the most fundamental notion is mathematics is that the left and > right sides of

Re: An oddity in list comparison and element assignment

2006-06-01 Thread michael . f . ellis
Yes. You stated it quite precisely. I believe l1==l2 should always return True and l1==l3 should always be False. (unless l3 is reassigned as l3=l1). Your idea of a separate operator for 'all elements have numerically equal values at the moment of comparision' is a good one. For want of a better

Re: An oddity in list comparison and element assignment

2006-06-01 Thread michael . f . ellis
Hi Tim, In your example, a & b are references to the same object. I agree they should compare equally. But please note that a==b is True at every point in your example, even after the ValueError raised by b.remove(1). That's good consistent behavior. My original example is a little different.

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Jim Segrave
In article <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> wrote: >Hi Alex, >With all due respect to your well-deserved standing in the Python >community, I'm not convinced that equality shouldn't imply invariance >under identical operations. > >Perhaps the most fundamental notion is mathematics is that

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > As to containers, would you say that envelope containing five $100 > bills is the same as an envelope containing a single $100 bill and 4 > xerox copies of it? If so, I'd like to engage in some envelope > exchanges with you :-) Would you say that envelope containing fi

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > As to containers, would you say that envelope containing five $100 > bills is the same as an envelope containing a single $100 bill and 4 > xerox copies of it? If so, I'd like to engage in some envelope > exchanges with you :-) if you spent as much time *learning* stuf

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Tim Peters
[EMAIL PROTECTED] > ... > As I see it, reference copying is a very useful performance and memory > optimization. But I don't think it should undermine the validity of > assert(a==b) as a predictor of invariance under identical operations. So, as Alex said last time, Try concisely expressing

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Tim Chase
> As to containers, would you say that envelope containing five $100 > bills is the same as an envelope containing a single $100 bill and 4 > xerox copies of it? If so, I'd like to engage in some envelope > exchanges with you :-) if len(set([bill.serialnumber for bill in envelope])) != len(envel

Re: An oddity in list comparison and element assignment

2006-06-01 Thread michael . f . ellis
oops! last sentence of 2nd paragraph in previous message should read "If my expectation is NOT met ..." -- http://mail.python.org/mailman/listinfo/python-list

Re: An oddity in list comparison and element assignment

2006-06-01 Thread michael . f . ellis
Hi Alex, With all due respect to your well-deserved standing in the Python community, I'm not convinced that equality shouldn't imply invariance under identical operations. Perhaps the most fundamental notion is mathematics is that the left and right sides of an equation remain identical after any

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > operations. I think what must be going on is that the 'b' list > contains replicated references instead of copies of [range(1,3)]*2 . Right. > IMO, python's == operator should detect this difference in list > structure since it leads to different behavior unde

An oddity in list comparison and element assignment

2006-06-01 Thread michael . f . ellis
The following script puzzles me. It creates two nested lists that compare identically. After identical element assignments, the lists are different. In one case, a single element is replaced. In the other, an entire column is replaced. ---