Re: newbie Q: sequence membership

2007-11-19 Thread Steven D'Aprano
On Mon, 19 Nov 2007 16:06:36 -0500, Sells, Fred wrote: >> >>> a, b = [], [] >> >>> a.append(b) >> >>> b.append(a) > did you perhaps mean a.append('b'); b.append('a'); otherwise this seems > pretty advanced for a newbie If you had bothered to read the rest of the post, you'd see that he meant exa

RE: newbie Q: sequence membership

2007-11-19 Thread Sells, Fred
> >>> a, b = [], [] > >>> a.append(b) > >>> b.append(a) did you perhaps mean a.append('b'); b.append('a'); otherwise this seems pretty advanced for a newbie > >>> b in a > True > >>> a in a > Traceback (most recent call last): > File "", line 1, in > RuntimeError: maximum recursion depth exce

Re: newbie Q: sequence membership

2007-11-19 Thread Gabriel Genellina
En Mon, 19 Nov 2007 03:32:12 -0300, saccade <[EMAIL PROTECTED]> escribió: > So if I am permitted to think of integers as immutable objects with > predefined labels (i.e. the integers used in the text of the program > code) that cannot de or re referenced then what a similar treatment of > characte

Re: newbie Q: sequence membership

2007-11-19 Thread John Machin
> > On Nov 17, 4:35 am, John Machin <[EMAIL PROTECTED]> wrote: >> Worse: Consider z = ['A1', 'Z9']. It's highly likely that when x == >> 'A1', "x is_in z" is True -- because an unguaranteed implementation- >> dependent caper caches or "interns" some values, so that x and z[0] >> are the same objec

Re: newbie Q: sequence membership

2007-11-18 Thread MonkeeSage
On Nov 19, 12:32 am, saccade <[EMAIL PROTECTED]> wrote: > I am not a programmer so I feel odd commenting about language design > decisions. When my Prof. introduced python the first question that > popped into mind was that since "x=9; y=9; print x is y and x == y" > prints "True" is there a way t

Re: newbie Q: sequence membership

2007-11-18 Thread saccade
On Nov 17, 3:40 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > You can write your own membership test based on identity ('is'): > Thank you for the practical (usable) advice and explanation of the '==' operator. On Nov 17, 4:35 am, John Machin <[EMAIL PROTECTED]> wrote: > > And that can

Re: newbie Q: sequence membership

2007-11-17 Thread John Machin
On Nov 17, 6:02 pm, saccade <[EMAIL PROTECTED]> wrote: > >>> a, b = [], [] > >>> a.append(b) > >>> b.append(a) > >>> b in a > True > >>> a in a > > Traceback (most recent call last): > File "", line 1, in > RuntimeError: maximum recursion depth exceeded in cmp > > >>> a is a[0] > False > >>> a =

Re: newbie Q: sequence membership

2007-11-17 Thread Gabriel Genellina
En Sat, 17 Nov 2007 04:02:12 -0300, saccade <[EMAIL PROTECTED]> escribió: a, b = [], [] a.append(b) b.append(a) b in a > True a in a > Traceback (most recent call last): > File "", line 1, in > RuntimeError: maximum recursion depth exceeded in cmp a is a[0] >

newbie Q: sequence membership

2007-11-16 Thread saccade
>>> a, b = [], [] >>> a.append(b) >>> b.append(a) >>> b in a True >>> a in a Traceback (most recent call last): File "", line 1, in RuntimeError: maximum recursion depth exceeded in cmp >>> >>> a is a[0] False >>> a == a[0] Traceback (most recent call last): File "", line 1, in RuntimeError: