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. ---

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 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 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 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
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 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
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 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-02 Thread michael . f . ellis
'. I haven't used such perjoratives in any of my posts and would appreciate the same courtesy. Cheers, Mike ''' StrongEquality -- a first cut at the definition proposed by M. Ellis. Author: Michael F. Ellis, Ellis & Grant, Inc. ''' def indices(ite

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