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[1]+=3, if very much

Re: Python dot-equals (syntax proposal)

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

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

Re: Python dot-equals (syntax proposal)

2010-05-02 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 Python

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 difference. It walks like

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.

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 with the object

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 practice though, I think that's a

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 try t=(1,2,3);

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Albert van der Horst
In article mailman.2429.1272646255.23598.python-l...@python.org, Jean-Michel Pichavant jeanmic...@sequans.com 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:

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: test lang=py3 t = ([],

Re: Python dot-equals (syntax proposal)

2010-05-01 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 pmau...@gmail.com wrote: On Apr 30, 11:04 am, Jabapyth jabap...@gmail.com wrote: At least a few times a day I wish python had the following

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

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

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

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Patrick Maupin
On May 1, 7:13 am, Tim Chase t...@thechases.com 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

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 lie.1...@gmail.com 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

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, and it

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 object

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Chris Rebert
On Sat, May 1, 2010 at 6:32 PM, Steven D'Aprano st...@remove-this-cybersource.com.au 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

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 st...@remove-this-cybersource.com.au 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

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Patrick Maupin
On May 1, 9:03 pm, Chris Rebert c...@rebertia.com 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,

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Aahz
In article 4bdcd631$0$27782$c3e8...@news.astraweb.com, Steven D'Aprano st...@remove-this-cybersource.com.au 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

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Alf P. Steinbach
On 02.05.2010 06:06, * Aahz: In article4bdcd631$0$27782$c3e8...@news.astraweb.com, Steven D'Apranost...@remove-this-cybersource.com.au 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

Re: Python dot-equals (syntax proposal)

2010-05-01 Thread Chris Rebert
On Sat, May 1, 2010 at 10:05 PM, Alf P. Steinbach al...@start.no wrote: On 02.05.2010 06:06, * Aahz: In article4bdcd631$0$27782$c3e8...@news.astraweb.com, Steven D'Apranost...@remove-this-cybersource.com.au  wrote: On Sat, 01 May 2010 07:13:42 -0500, Tim Chase wrote: The += family of

Python dot-equals (syntax proposal)

2010-04-30 Thread Jabapyth
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] # vbl = vbl.[some

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

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 D'Arcy J.M. Cain
On Fri, 30 Apr 2010 09:04:59 -0700 (PDT) Jabapyth jabap...@gmail.com 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

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 a cost, too. A

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 John Bokma
D'Arcy J.M. Cain da...@druid.net writes: On Fri, 30 Apr 2010 09:04:59 -0700 (PDT) Jabapyth jabap...@gmail.com 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

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Chris Rebert
On Fri, Apr 30, 2010 at 10:05 AM, John Bokma j...@castleamber.com wrote: D'Arcy J.M. Cain da...@druid.net writes: On Fri, 30 Apr 2010 09:04:59 -0700 (PDT) Jabapyth jabap...@gmail.com wrote: foo = Hello world foo.=split( ) Isn't; foo = Hello world bar = foo.split() # side note - split()

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 j...@castleamber.com wrote: D'Arcy J.M. Cain da...@druid.net 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

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: snip currentCar = Car() currentCar = currentCar.nextCar The syntax you prose will be applicable on very little assignements (use case 3). I'm not

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread John Bokma
Chris Rebert c...@rebertia.com writes: On Fri, Apr 30, 2010 at 10:05 AM, John Bokma j...@castleamber.com 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

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Aahz
In article 87zl0klvki@castleamber.com, John Bokma j...@castleamber.com 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

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Brendan Abel
On Apr 30, 9:04 am, Jabapyth jabap...@gmail.com 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 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 your variables

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 Patrick Maupin
On Apr 30, 11:04 am, Jabapyth jabap...@gmail.com 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