Re: Python dot-equals (syntax proposal)

2010-05-03 Thread Terry Reedy
On 5/3/2010 12:37 AM, Alf P. Steinbach wrote: * Terry Reedy: * Alf P. Steinbach: * Aahz: and sometimes they rebind the original target to the same object. At the Python level that seems to be an undetectable null-operation. If you try t=(1,2,3); t[1]+=3, if very much matters that a rebin

Re: Python dot-equals (syntax proposal)

2010-05-03 Thread Peter Otten
Alf P. Steinbach wrote: > > >>> t = ([], [], []) > >>> t > ([], [], []) > >>> t[0] += ["blah"] > Traceback (most recent call last): > File "", line 1, in > TypeError: 'tuple' object does not support item assignment > >>> t > (['blah'], [], []) > >>> _ > > > Yep, it matters. > > Is this change

Re: Python dot-equals (syntax proposal)

2010-05-03 Thread Steven D'Aprano
On Mon, 03 May 2010 06:37:49 +0200, Alf P. Steinbach wrote: > * Terry Reedy: >> * Alf P. Steinbach: >>> * Aahz: >> and sometimes they rebind the original target to the same object. >>> >>> At the Python level that seems to be an undetectable null-operation. >> >> If you try t=(1,2,3); t[

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Alf P. Steinbach
* Terry Reedy: * Alf P. Steinbach: * Aahz: and sometimes they rebind the original target to the same object. At the Python level that seems to be an undetectable null-operation. If you try t=(1,2,3); t[1]+=3, if very much matters that a rebind occurs. Testing: >>> t = ([], [], []) >>>

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Albert van der Horst
In article , Jean-Michel Pichavant wrote: >Jabapyth wrote: >> At least a few times a day I wish python had the following shortcut >> syntax: >> >> vbl.=func(args) >> >> this would be equivalent to >> >> vbl = vbl.func(args) >> >> example: >> >> foo = "Hello world" >> foo.=split(" ") >> print foo

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Steven D'Aprano
On Sun, 02 May 2010 04:04:11 -0400, Terry Reedy wrote: > On 5/2/2010 1:05 AM, Alf P. Steinbach wrote: >> On 02.05.2010 06:06, * Aahz: > >>> and sometimes >>> they rebind the original target to the same object. >> >> At the Python level that seems to be an undetectable null-operation. > > If you

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Steven D'Aprano
On Sun, 02 May 2010 17:09:36 +1000, Lie Ryan wrote: > On 05/02/10 10:58, Steven D'Aprano wrote: >> On Sun, 02 May 2010 05:08:53 +1000, Lie Ryan wrote: >> >>> > On 05/01/10 11:16, Steven D'Aprano wrote: >> On Fri, 30 Apr 2010 12:34:34 -0400, D'Arcy J.M. Cain wrote: >> >> In practic

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Steven D'Aprano
On Sun, 02 May 2010 16:28:28 +1000, Lie Ryan wrote: > On 05/02/10 10:58, Steven D'Aprano wrote: >>> > And Python's object system >>> > makes it that the argument to __getattr__ is always a string even >>> > though there might be a valid variable that corresponds to it: >> That is nothing to do wit

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Terry Reedy
On 5/2/2010 1:05 AM, Alf P. Steinbach wrote: On 02.05.2010 06:06, * Aahz: and sometimes they rebind the original target to the same object. At the Python level that seems to be an undetectable null-operation. If you try t=(1,2,3); t[1]+=3, if very much matters that a rebind occurs. Grant

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Lie Ryan
On 05/02/10 10:58, Steven D'Aprano wrote: > On Sun, 02 May 2010 05:08:53 +1000, Lie Ryan wrote: > >> > On 05/01/10 11:16, Steven D'Aprano wrote: >>> >> On Fri, 30 Apr 2010 12:34:34 -0400, D'Arcy J.M. Cain wrote: >>> >> >>> >> In practice though, I think that's a difference that makes no >>> >> di

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Lie Ryan
On 05/02/10 10:58, Steven D'Aprano wrote: >> > And Python's object system >> > makes it that the argument to __getattr__ is always a string even though >> > there might be a valid variable that corresponds to it: > That is nothing to do with the object system, it is related to the > semantics of P

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Chris Rebert
On Sat, May 1, 2010 at 10:05 PM, Alf P. Steinbach wrote: > On 02.05.2010 06:06, * Aahz: >> In article<4bdcd631$0$27782$c3e8...@news.astraweb.com>, >> Steven D'Aprano  wrote: >>> >>> On Sat, 01 May 2010 07:13:42 -0500, Tim Chase wrote: The += family of operators really do rebind the symbo

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Alf P. Steinbach
On 02.05.2010 06:06, * Aahz: In article<4bdcd631$0$27782$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: On Sat, 01 May 2010 07:13:42 -0500, Tim Chase wrote: The += family of operators really do rebind the symbol, not modify the object. They potentially do both, depending on the object,

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Aahz
In article <4bdcd631$0$27782$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: >On Sat, 01 May 2010 07:13:42 -0500, Tim Chase wrote: >> >> The += family of operators really do rebind the symbol, not modify the >> object. > >They potentially do both, depending on the object, even for built-ins.

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Patrick Maupin
On May 1, 9:03 pm, Chris Rebert wrote: > In both cases, __iOP__ operator methods are being used, not vanilla > __OP__ methods, so neither of your examples are relevant to Mr. > Chase's point. Well, Tim's main assertion was: "The += family of operators really do rebind the symbol, not modify the o

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Steven D'Aprano
On Sat, 01 May 2010 19:03:04 -0700, Chris Rebert wrote: > On Sat, May 1, 2010 at 6:32 PM, Steven D'Aprano > wrote: >> On Sat, 01 May 2010 07:13:42 -0500, Tim Chase wrote: >>> This doesn't preclude you from implementing a self-mutating += style >>> __add__ method and returning "self", but it's usu

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Chris Rebert
On Sat, May 1, 2010 at 6:32 PM, Steven D'Aprano wrote: > On Sat, 01 May 2010 07:13:42 -0500, Tim Chase wrote: >> This doesn't preclude you from implementing a self-mutating += style >> __add__ method and returning "self", but it's usually a bad idea > > Obviously the Python dev team don't agree wi

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Steven D'Aprano
On Sat, 01 May 2010 07:13:42 -0500, Tim Chase wrote: > On 05/01/2010 12:08 AM, Patrick Maupin wrote: >> +=, -=, /=, *=, etc. conceptually (and, if lhs object supports in- >> place operator methods, actually) *modify* the lhs object. >> >> Your proposed .= syntax conceptually *replaces* the lhs ob

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Steven D'Aprano
On Sun, 02 May 2010 05:08:53 +1000, Lie Ryan wrote: > On 05/01/10 11:16, Steven D'Aprano wrote: >> On Fri, 30 Apr 2010 12:34:34 -0400, D'Arcy J.M. Cain wrote: >> >> In practice though, I think that's a difference that makes no >> difference. It walks like an operator, it swims like an operator, a

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread D'Arcy J.M. Cain
On Sun, 02 May 2010 05:08:53 +1000 Lie Ryan wrote: > On 05/01/10 11:16, Steven D'Aprano wrote: > > On Fri, 30 Apr 2010 12:34:34 -0400, D'Arcy J.M. Cain wrote: > > > > In practice though, I think that's a difference that makes no difference. > > It walks like an operator, it swims like an operato

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Patrick Maupin
On May 1, 7:13 am, Tim Chase wrote: > On 05/01/2010 12:08 AM, Patrick Maupin wrote: > > > +=, -=, /=, *=, etc.  conceptually (and, if lhs object supports in- > > place operator methods, actually) *modify* the lhs object. > > > Your proposed .= syntax conceptually *replaces* the lhs object > > (act

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Lie Ryan
On 05/01/10 11:16, Steven D'Aprano wrote: > On Fri, 30 Apr 2010 12:34:34 -0400, D'Arcy J.M. Cain wrote: > > In practice though, I think that's a difference that makes no difference. > It walks like an operator, it swims like an operator, and it quacks like > an operator. > Nope it's not. A ful

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Alf P. Steinbach
On 01.05.2010 14:13, * Tim Chase: On 05/01/2010 12:08 AM, Patrick Maupin wrote: +=, -=, /=, *=, etc. conceptually (and, if lhs object supports in- place operator methods, actually) *modify* the lhs object. Your proposed .= syntax conceptually *replaces* the lhs object (actually, rebinds the lhs

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Stefan Behnel
Tim Chase, 01.05.2010 14:13: On 05/01/2010 12:08 AM, Patrick Maupin wrote: +=, -=, /=, *=, etc. conceptually (and, if lhs object supports in- place operator methods, actually) *modify* the lhs object. Your proposed .= syntax conceptually *replaces* the lhs object (actually, rebinds the lhs symb

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Tim Chase
On 05/01/2010 12:08 AM, Patrick Maupin wrote: +=, -=, /=, *=, etc. conceptually (and, if lhs object supports in- place operator methods, actually) *modify* the lhs object. Your proposed .= syntax conceptually *replaces* the lhs object (actually, rebinds the lhs symbol to the new object). The

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Simon
Hay I got a better idea. If you put two dots (..) on a line by itself it means execute the previous line again! On 1 May 2010 07:08, Patrick Maupin wrote: > On Apr 30, 11:04 am, Jabapyth wrote: > > At least a few times a day I wish python had the following shortcut > > syntax: > > > > vbl.=func

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Patrick Maupin
On Apr 30, 11:04 am, Jabapyth wrote: > At least a few times a day I wish python had the following shortcut > syntax: > > vbl.=func(args) > > this would be equivalent to > > vbl = vbl.func(args) > > example: > > foo = "Hello world" > foo.=split(" ") > print foo > # ['Hello', 'world'] > > and I gues

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Steven D'Aprano
On Fri, 30 Apr 2010 12:34:34 -0400, D'Arcy J.M. Cain wrote: > I assume you mean the former to be analagous to "+=" and friends but I > am not sure since "." isn't an operator. It's a de facto operator. If you google on "python dot operator" you will find many people who refer to it as such, and

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Steven D'Aprano
On Fri, 30 Apr 2010 18:50:46 +0200, Jean-Michel Pichavant wrote: > Jabapyth wrote: >> At least a few times a day I wish python had the following shortcut >> syntax: >> >> vbl.=func(args) >> >> this would be equivalent to >> >> vbl = vbl.func(args) [...] > Useless if you use meaningful names for yo

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Brendan Abel
On Apr 30, 9:04 am, Jabapyth wrote: > At least a few times a day I wish python had the following shortcut > syntax: > > vbl.=func(args) > > this would be equivalent to > > vbl = vbl.func(args) > > example: > > foo = "Hello world" > foo.=split(" ") > print foo > # ['Hello', 'world'] > > and I guess

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Aahz
In article <87zl0klvki@castleamber.com>, John Bokma wrote: > >Why I am asking this is that most "Oh, like Perl" statements I've seen >the past months were made by people who either haven't used Perl >themselves or have very little skill in the language. What evidence do you have for your as

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread John Bokma
Chris Rebert writes: > On Fri, Apr 30, 2010 at 10:05 AM, John Bokma wrote: [..] >> On top of that, it's not possible in Perl (heh, no surprise there). The >> only thing that comes close is: > > Actually/ironically, it does appear to be in Perl 6: > """ > Mutating method call > $obj.=meth >

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Lie Ryan
On 05/01/10 02:50, Jean-Michel Pichavant wrote: > Jabapyth wrote: >> At least a few times a day I wish python had the following shortcut >> syntax: > currentCar = Car() > currentCar = currentCar.nextCar > > The syntax you prose will be applicable on very little assignements (use > case 3). I'm no

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread D'Arcy J.M. Cain
On Fri, 30 Apr 2010 12:05:49 -0500 John Bokma wrote: > "D'Arcy J.M. Cain" writes: > > so much clearer? Do you really want to see Python turn into Perl? > > Oh, boy, there we go again. Can you and your buddies please refrain from > using Perl as a kind of uber-argument? Just write why you think

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Chris Rebert
On Fri, Apr 30, 2010 at 10:05 AM, John Bokma wrote: > "D'Arcy J.M. Cain" writes: >> On Fri, 30 Apr 2010 09:04:59 -0700 (PDT) >> Jabapyth wrote: >>> foo = "Hello world" >>> foo.=split(" ") >> >> Isn't; >> >> foo = "Hello world" >> bar = foo.split() # side note - split() splits on whitespace by de

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread John Bokma
"D'Arcy J.M. Cain" writes: > On Fri, 30 Apr 2010 09:04:59 -0700 (PDT) > Jabapyth wrote: >> foo = "Hello world" >> foo.=split(" ") > > Isn't; > > foo = "Hello world" > bar = foo.split() # side note - split() splits on whitespace by default > > so much clearer? Do you really want to see Python tu

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Jean-Michel Pichavant
Jabapyth wrote: At least a few times a day I wish python had the following shortcut syntax: vbl.=func(args) this would be equivalent to vbl = vbl.func(args) example: foo = "Hello world" foo.=split(" ") print foo # ['Hello', 'world'] and I guess you could generalize this to vbl.=[some text]

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Peter Otten
Jabapyth wrote: > At least a few times a day I wish python had the following shortcut > syntax: > > vbl.=func(args) > > this would be equivalent to > > vbl = vbl.func(args) > > example: > > foo = "Hello world" > foo.=split(" ") > print foo > # ['Hello', 'world'] Extending a language comes at

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread D'Arcy J.M. Cain
On Fri, 30 Apr 2010 09:04:59 -0700 (PDT) Jabapyth wrote: > foo = "Hello world" > foo.=split(" ") Isn't; foo = "Hello world" bar = foo.split() # side note - split() splits on whitespace by default so much clearer? Do you really want to see Python turn into Perl? However, if you really want to

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Stefan Behnel
J. Cliff Dyer, 30.04.2010 18:20: On Fri, 2010-04-30 at 09:04 -0700, Jabapyth wrote: At least a few times a day I wish python had the following shortcut syntax: vbl.=func(args) this would be equivalent to vbl = vbl.func(args) example: foo = "Hello world" foo.=split(" ") print foo # ['Hello',

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread J. Cliff Dyer
That's kind of a nifty idea. However, python is currently under a syntax moratorium. No syntax changes will be accepted for at least 24 months starting from the release date of Python 3.1. See more details here: http://www.python.org/dev/peps/pep-3003/ Cheers, Cliff On Fri, 2010-04-30 at 09:0