Re: list in a tuple

2007-12-28 Thread vjktm
On Dec 28, 1:34 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 27 Dec 2007 16:38:07 -0300, <[EMAIL PROTECTED]> escribió: > > > > > On Dec 27, 8:20 pm, Wildemar Wildenburger > > <[EMAIL PROTECTED]> wrote: > > >> From that post: > >> > Ok, I do admit that doing > > >> > a = ([1], 2)

Re: list in a tuple

2007-12-27 Thread Gabriel Genellina
En Thu, 27 Dec 2007 16:38:07 -0300, <[EMAIL PROTECTED]> escribió: > On Dec 27, 8:20 pm, Wildemar Wildenburger > <[EMAIL PROTECTED]> wrote: >> > >> >> From that post: >> > Ok, I do admit that doing >> > >> > a = ([1], 2) >> > a[0].append(2) >> > >> > also doesn't throw an error, but this onl

Re: list in a tuple

2007-12-27 Thread montyphyton
Carl Banks wrote: > On Dec 27, 12:38 pm, [EMAIL PROTECTED] wrote: >> After some tought I must agree that this is a wart more than >> a bug and that it will probably be best not to mess with it. >> However, what do you guys think about the print wart in Py3k >> described >> athttp://filoxus.blogspo

Re: list in a tuple

2007-12-27 Thread Carl Banks
On Dec 27, 12:38 pm, [EMAIL PROTECTED] wrote: > After some tought I must agree that this is a wart more than > a bug and that it will probably be best not to mess with it. > However, what do you guys think about the print wart in Py3k > described > athttp://filoxus.blogspot.com/2007/12/python-3000

Re: list in a tuple

2007-12-27 Thread montyphyton
On Dec 27, 8:20 pm, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > > > > From that post: > > Ok, I do admit that doing > > > > a = ([1], 2) > > a[0].append(2) > > > > also doesn't throw an error, but this only confuses me more. > > > Why? You mutate thelist, but thetupledoes not chan

Re: list in a tuple

2007-12-27 Thread Wildemar Wildenburger
Subject: Re: list in a tuple To: Cc: Bcc: Reply-To: Newsgroup: comp.lang.python -=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=- [EMAIL PROTECTED] wrote: > After some tought I must agree that this is a wart more than > a bug and that it will probably be best not to m

Re: list in a tuple

2007-12-27 Thread montyphyton
After some tought I must agree that this is a wart more than a bug and that it will probably be best not to mess with it. However, what do you guys think about the print wart in Py3k described at http://filoxus.blogspot.com/2007/12/python-3000-how-mutable-is-immutable.html#links (im not trying to

Re: list in a tuple

2007-12-26 Thread Arnaud Delobelle
On Dec 26, 1:08 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Mon, 24 Dec 2007 18:01:53 -0800, Raymond Hettinger wrote: [...] > > The first succeeds and the second fails. > > And this is a good idea? > > Shouldn't the tuple assignment raise the exception BEFORE calling > __

Re: list in a tuple

2007-12-25 Thread Steven D'Aprano
On Mon, 24 Dec 2007 18:01:53 -0800, Raymond Hettinger wrote: >> Currently, Python raises an error *and* changes the first element of >> the tuple. Now, this seems like something one would want to change - >> why raise an error *and* execute the thing it was complaining about? > > Yawn. Multiple

Re: list in a tuple

2007-12-24 Thread Raymond Hettinger
On Dec 24, 8:22 am, [EMAIL PROTECTED] wrote: > Recently, I got into a debate on programming.reddit.com about > what should happen in the following case: > > >>> a = ([1], 2) > >>> a[0] += [3] > > Currently, Python raises an error *and* changes the first element of > the tuple. Now, this seems like

Re: list in a tuple

2007-12-24 Thread Arnaud Delobelle
On Dec 24, 4:13 pm, [EMAIL PROTECTED] wrote: > Like I said, it is clear *why* this happens, what I > am concerned is if this what we *want* to happen, i.e., > if the current situation is satisfying. Your mytuple class > would be something that resembles a solution, my question > is what the people

Re: list in a tuple

2007-12-24 Thread Arnaud Delobelle
On Dec 24, 4:08 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: [...] > class mytuple(tuple): >     "It's ok to do t[i] = obj as long as t[i] was already obj" >     def __setitem__(self, i, val): >         if self[i] is not val: >             raise TypeError("'mytuple' object is immutable") > > So:

Re: list in a tuple

2007-12-24 Thread montyphyton
Like I said, it is clear *why* this happens, what I am concerned is if this what we *want* to happen, i.e., if the current situation is satisfying. Your mytuple class would be something that resembles a solution, my question is what the people on this group think about it. On Dec 24, 5:08 pm, Arna

Re: list in a tuple

2007-12-24 Thread Arnaud Delobelle
On Dec 24, 3:22 pm, [EMAIL PROTECTED] wrote: > Recently, I got into a debate on programming.reddit.com about > what should happen in the following case: > > >>> a = ([1], 2) > >>> a[0] += [3] > > Currently, Python raises an error *and* changes the first element of > the tuple. Now, this seems like

list in a tuple

2007-12-24 Thread montyphyton
Recently, I got into a debate on programming.reddit.com about what should happen in the following case: >>> a = ([1], 2) >>> a[0] += [3] Currently, Python raises an error *and* changes the first element of the tuple. Now, this seems like something one would want to change - why raise an error *an