Re: append on lists

2008-09-18 Thread Steve Holden
Armin wrote: > Duncan Booth wrote: >> "Chris Rebert" <[EMAIL PROTECTED]> wrote: >>> On Tue, Sep 16, 2008 at 1:20 AM, Armin <[EMAIL PROTECTED]> wrote: [1,2,3,4,7].append(c) -> Is this a valid expression? >>> Literally, no, because you can't call methods on literals. >> >> Rubbish. There is no

Re: append on lists

2008-09-18 Thread Steve Holden
[EMAIL PROTECTED] wrote: > On Sep 16, 6:03 am, Peter Anderson <[EMAIL PROTECTED]> > wrote: >> "/... I don't think you've thought this one through, really./" >> snip >> >> We ought to try and be a little kinder to others on the list, don't you >> think? :-) >> >> snip > > Well said! >From personal

Re: append on lists

2008-09-17 Thread Lie
On Sep 16, 3:20 pm, Armin <[EMAIL PROTECTED]> wrote: > John Machin wrote: > > On Sep 16, 6:45 am, Armin <[EMAIL PROTECTED]> wrote: > > >> Yes, but this is very unconvenient. > >> If d should reference the list a extended with a single list element > >> you need at least two lines > > >> a.append(7)

Re: append on lists

2008-09-16 Thread J. Cliff Dyer
On Tue, 2008-09-16 at 08:49 -0500, Grant Edwards wrote: > On 2008-09-16, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > > Duncan Booth <[EMAIL PROTECTED]> writes: > > > >> The only relatively common use I can think of where you might want to call > >> a method directly on a literal is to produce a li

Re: literals optimization (was Re: append on lists)

2008-09-16 Thread Grant Edwards
On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > Le Tuesday 16 September 2008 18:26:38 Grant Edwards, vous avez ?crit?: >> I was asking where in the specification >> it says that all >> expressions that return something, return a new object. ? > > I n

Re: literals optimization (was Re: append on lists)

2008-09-16 Thread Terry Reedy
Maric Michaud wrote: Le Tuesday 16 September 2008 16:57:26 Grant Edwards, vous avez écrit : Where is that in the specification? Each literal creates a new instance, This does not answer 'where' but just adds another false claim. I just reread the Reference Manual, Lexical Analysis chapt

Re: append on lists

2008-09-16 Thread Terry Reedy
Maric Michaud wrote: Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit : On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: all expressions that return something, return a new object, That's not _quite_ true: a=1 b=a.__add__(0) a is b True ;) This is implementation

Re: append on lists

2008-09-16 Thread Terry Reedy
Maric Michaud wrote: It is, please try to understand it, in python all expressions that mutate an object should return None, You are over-generalizing. For builtin classes, mutation methods return none. Guido recommends this as a general practice, but users may do whatever they like in the

Re: literals optimization (was Re: append on lists)

2008-09-16 Thread Grant Edwards
On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > Le Tuesday 16 September 2008 18:26:38 Grant Edwards, vous avez écrit : >> I was asking where in the specification >> it says that all expressions that >> return something, return a >> new object.   > > I

Re: literals optimization (was Re: append on lists)

2008-09-16 Thread Maric Michaud
Le Tuesday 16 September 2008 18:26:38 Grant Edwards, vous avez écrit : > I was asking where in the specification > it says that all expressions that > return something, return a > new object.   I never said this, I said it's the spirit of python APIs, with som

Re: literals optimization (was Re: append on lists)

2008-09-16 Thread Grant Edwards
On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > Le Tuesday 16 September 2008 16:57:26 Grant Edwards, vous avez écrit : >> On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: >> > Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit : >> >> On 2008-09-16, Maric Michaud

Re: literals optimization (was Re: append on lists)

2008-09-16 Thread Maric Michaud
Le Tuesday 16 September 2008 16:57:26 Grant Edwards, vous avez écrit : > On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > > Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit : > >> On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > >> > all expressions that return

Re: append on lists

2008-09-16 Thread Grant Edwards
On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit : >> On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: >> > all expressions that return something, return a new object, >> >> That's not _quite_ true: >> >>> a=1 >> >

Re: append on lists

2008-09-16 Thread Maric Michaud
Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit : > On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > > all expressions that return something, return a new object, > > That's not _quite_ true: > >>> a=1 > >>> b=a.__add__(0) > >>> a is b > > True > > ;) This is implemen