Re: Why is augmented assignment of a tuple with iterable unpacking invalid syntax?

2019-05-19 Thread Piet van Oostrum
Eugene Alterman writes: > a = 1, 2, 3 > > b = *a, # assignment - OK > b += *a, # augmented assignment - syntax error > > Need to enclose in parenthesis: > > b += (*a,) > > Why isn't it allowed with an augmented assignment, while i

Why is augmented assignment of a tuple with iterable unpacking invalid syntax?

2019-05-19 Thread Eugene Alterman
a = 1, 2, 3 b = *a, # assignment - OK b += *a, # augmented assignment - syntax error Need to enclose in parenthesis: b += (*a,) Why isn't it allowed with an augmented assignment, while it is OK with a regular assignment? -- https://mail.python.org/mailman/listinfo/p

Re: TypeError expected in an augmented assignment

2014-07-03 Thread Mark Lawrence
On 03/07/2014 10:35, candide wrote: >From that link: """ An augmented assignment expression like x += 1 can be rewritten as x = x + 1 to achieve a similar, but not exactly equal effect. In the augmented version, x is only evaluated once. Also, when possible, the a

Re: TypeError expected in an augmented assignment

2014-07-03 Thread candide
> >From that link: > > > > """ > > An augmented assignment expression like x += 1 can be rewritten as x = > > x + 1 to achieve a similar, but not exactly equal effect. In the > > augmented version, x is only evaluated once. Also, when

Re: TypeError expected in an augmented assignment

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 5:51 PM, candide wrote: > Good and interesting observation. But I can't find out where this feature is > referenced in the Language/Library Reference. Because, as my first post > explains, augmented assignment performs the binary operation associated to &

Re: TypeError expected in an augmented assignment

2014-07-03 Thread candide
seq+= {5, 6} # the order of extending is not determined > > >>> seq > > [1, 2, 3, 4, 5, 6] > > >>> Good and interesting observation. But I can't find out where this feature is referenced in the Language/Library Reference. Because, as my first p

Re: TypeError expected in an augmented assignment

2014-07-02 Thread Terry Reedy
On 7/2/2014 10:39 PM, candide wrote: An hybrid list-tuple concatenation is not allowed []+(1, 2) Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate list (not "tuple") to list hence I was expecting (*) that the following code raises a TypeError :

TypeError expected in an augmented assignment

2014-07-02 Thread candide
>>> [1, 2] >>> Any explanation ? (*) as the docs states, the augmented assignment is supposed to perform the concatenation : An augmented assignment (...) performs the binary operation specific to the type of assignment on the two operands (...) -- https://mail.python.org/mailman/listinfo/python-list

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Aahz
ow wrong it was until now. It's true almost everywhere except augmented assignment. Augmented assignment is a prime example of the compromises one needs to make in adding features. -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "And if that m

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Aahz
In article <[EMAIL PROTECTED]>, OKB (not okblacke) <[EMAIL PROTECTED]> wrote: > > This sentence is phrased as though it is the whole story, but it >isn't, because the operation might not in fact wind up being an >assignment. Shouldn't there be an "except see below" or something >there, to

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Roel Schroeven
object does not support item assignment > >> Obviously, you can easily work around it: >> >>>>> t = ([],) >>>>> l = t[0] >>>>> l += ['foo'] >>>>> t >> (['foo'],) > > This is quite shock

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread OKB (not okblacke)
you can easily work around it: > >>>> t = ([],) >>>> l = t[0] >>>> l += ['foo'] >>>> t > (['foo'],) This is quite shocking to me, although after staring at the documentation for a while I guess I understand it. But

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Roel Schroeven
LOAD_CONST 0 (None) > 22 RETURN_VALUE > > Notice the critical sequence: BINARY_SUBSCR, INPLACE_ADD, STORE_SUBSCR. > It has to work that way to allow this: > >>>> l = [7] >>>> l[0] += 1 >>>> l > [8] > >

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Aahz
In article <[EMAIL PROTECTED]>, Roel Schroeven <[EMAIL PROTECTED]> wrote: >Aahz schreef: >> >> Although Alex is essentially correct, the situation is a bit more complex >> and you are correct that augmented assignment allows the object to decide >> wh

Re: Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Roel Schroeven
guage Reference seems a little confused about the >>>> terminology. >>>> >>>> 3.4.7 Emulating numeric types >>>> 6.3.1 Augmented assignment statements >>>> >>>> The former refers to "augmented arithmetic operations", whi

Augmented assignment (was Re: Something in the function tutorial confused me.)

2007-08-11 Thread Aahz
the >>> terminology. >>> >>> 3.4.7 Emulating numeric types >>> 6.3.1 Augmented assignment statements >>> >>> The former refers to "augmented arithmetic operations", which I >>> think is a nice terminology, since assignment

Re: Nested scopes, and augmented assignment

2006-07-10 Thread Piet van Oostrum
> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >AP> I'm sorry to see you missed it, but since I had answered this already in >AP> this thread I saw at the moment no need to repeat it: There would be no >AP> value for c, the line would raise an UnboundLocalError. OK. That could have been chos

Re: Nested scopes, and augmented assignment

2006-07-10 Thread Antoon Pardon
This is probably my last response to you in this thread. My impression is that for the moment nothing productive can come from this exchange. I have the feeling that you are not reading so much with the interntion of understanding what I want to say, but with the intention of confirming your suspit

Re: Nested scopes, and augmented assignment

2006-07-09 Thread Piet van Oostrum
> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >AP> When someone gets confused over the difference between rebinding or >AP> mutating a variable on an intermediate scope, the explanation he >AP> mostly seems to get boils down to: one is rebinding, the other is >AP> mutation, this is a fundame

Re: Nested scopes, and augmented assignment

2006-07-09 Thread Antoon Pardon
On 2006-07-08, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On 8 Jul 2006 18:52:56 GMT, Antoon Pardon <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > >> >> I'm not fooled by that phrase. I just think the mutate vs rebind >> explanation is not complete. >> >> If we have tw

Re: Nested scopes, and augmented assignment

2006-07-09 Thread Antoon Pardon
On 2006-07-09, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: > >>AP> It is conceptually different. In the line 'a = b' you don't need to >>AP> search for the scope of a. You know it is the current scope, if you > > Except when it has been declared

Re: Nested scopes, and augmented assignment

2006-07-09 Thread Piet van Oostrum
> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >AP> It is conceptually different. In the line 'a = b' you don't need to >AP> search for the scope of a. You know it is the current scope, if you Except when it has been declared global. >AP> want to know the scope of b on the other hand, you n

Re: Nested scopes, and augmented assignment

2006-07-08 Thread Antoon Pardon
On 2006-07-07, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: > >>AP> On 2006-07-07, Piet van Oostrum <[EMAIL PROTECTED]> wrote: > Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >>AP> Could you maybe clarify what problem we are discussi

Re: Nested scopes, and augmented assignment

2006-07-08 Thread Antoon Pardon
On 2006-07-07, Terry Reedy <[EMAIL PROTECTED]> wrote: > > "Antoon Pardon" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> And if Nested variables are harmfull, > > I don't know if anyone said that they were, but Guido obviously does not > think so, or he would not have added the

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Piet van Oostrum
> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >AP> On 2006-07-07, Piet van Oostrum <[EMAIL PROTECTED]> wrote: Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >>> >AP> Could you maybe clarify what problem we are discussing? All I wrote >AP> was that with an assignment the search for t

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Terry Reedy
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > others might be helped if you took the trouble of explaining > what was wrong. Aside from F., I tried to explain what I think you said wrong. Did you read it? Did it help any? tjr -- http://mail.python.org/mai

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Bruno Desthuilliers
Fredrik Lundh wrote: > Bruno Desthuilliers wrote: > >> Certainly not. Nested scopes allow closures, which allow decorators and >> lot of *very* useful things. > > > decorators can be trivially implemented as classes, of course. it's a > bit unfortunate that many people seem to think that decora

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Antoon Pardon
On 2006-07-07, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: > >>> have any of your "my mental model of how Python works is more important >>> than how it actually works" ever had a point ? >> >> Be free to correct me. But just suggesting that I'm wrong doesn't help >> me in cha

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Antoon Pardon
On 2006-07-07, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Antoon "I'm no nincompoop, but I play one on the internet" Pardon wrote: > >> I don't see the contradiction. That Namespaces and names lookup are >> fundamentel parts of the Python language, doesn't mean that >> the right behaviour can't be

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Antoon Pardon
On 2006-07-07, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: > >>AP> Could you maybe clarify what problem we are discussing? All I wrote >>AP> was that with an assignment the search for the lefthand variable >>AP> depends on whether the lefthand si

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Fredrik Lundh
Bruno Desthuilliers wrote: > Certainly not. Nested scopes allow closures, which allow decorators and > lot of *very* useful things. decorators can be trivially implemented as classes, of course. it's a bit unfortunate that many people seem to think that decorators *have* to be implemented as n

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Bruno Desthuilliers
Antoon Pardon wrote: > On 2006-07-06, Piet van Oostrum <[EMAIL PROTECTED]> wrote: > > >>>AP> Aren't we now talking about implementation details? Sure the compilor >>>AP> can set things up so that local names are bound to the local scope and >>>AP> so the same code can be used. But it seems somewh

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Bruno Desthuilliers
Piet van Oostrum wrote: (snip) > There is no big difference I think. Only Python doesn't have syntax for the > former. Older versions of Python didn't even have nested scopes. maybe it > was a mistake to add them. Certainly not. Nested scopes allow closures, which allow decorators and lot of *very

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Bruno Desthuilliers
Antoon Pardon wrote: > On 2006-07-06, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > >>Antoon Pardon wrote: >> >>>On 2006-07-05, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >>> >>> >>>It's not about "finding a name/identifier", it's about the difference >>>between (re)binding a name and

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Fredrik Lundh
Piet van Oostrum wrote: > There is no big difference I think. Only Python doesn't have syntax for the > former. Older versions of Python didn't even have nested scopes. arbitrarily nested scopes, at least. the old local/global/builtin approach (the LGB rule) is of course a kind of nesting; the

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Fredrik Lundh
Antoon "I'm no nincompoop, but I play one on the internet" Pardon wrote: > I don't see the contradiction. That Namespaces and names lookup are > fundamentel parts of the Python language, doesn't mean that > the right behaviour can't be implemented in multiple ways and > doesn't contradict that a

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Piet van Oostrum
> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >AP> Could you maybe clarify what problem we are discussing? All I wrote >AP> was that with an assignment the search for the lefthand variable >AP> depends on whether the lefthand side is a simple variable or >AP> more complicated. What do you

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Piet van Oostrum
> "Terry Reedy" <[EMAIL PROTECTED]> (TR) wrote: >TR> "Antoon Pardon" <[EMAIL PROTECTED]> wrote in message >TR> news:[EMAIL PROTECTED] >>> And if Nested variables are harmfull, >TR> I don't know if anyone said that they were, but Guido obviously does not >TR> think so, or he would not have

Re: Nested scopes, and augmented assignment

2006-07-07 Thread Fredrik Lundh
Antoon Pardon wrote: >> have any of your "my mental model of how Python works is more important >> than how it actually works" ever had a point ? > > Be free to correct me. But just suggesting that I'm wrong doesn't help > me in changing my mental model. over the years, enough people have waste

Re: Nested scopes, and augmented assignment

2006-07-06 Thread Terry Reedy
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > And if Nested variables are harmfull, I don't know if anyone said that they were, but Guido obviously does not think so, or he would not have added them. So skip that. > what is then the big difference between rebi

Re: Nested scopes, and augmented assignment

2006-07-06 Thread Antoon Pardon
On 2006-07-06, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: >> On 2006-07-05, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >> >>It's not about "finding a name/identifier", it's about the difference >>between (re)binding a name and mutating an object. >>> AP> The

Re: Nested scopes, and augmented assignment

2006-07-06 Thread Antoon Pardon
On 2006-07-06, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >>AP> Aren't we now talking about implementation details? Sure the compilor >>AP> can set things up so that local names are bound to the local scope and >>AP> so the same code can be used. But it seems somewhere was made the >>AP> decision

Re: Nested scopes, and augmented assignment

2006-07-06 Thread Piet van Oostrum
> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >AP> Well if someone explains what is wrong about my understanding, I >AP> certainly care about that (although I confess to sometimes being >AP> impatient) but someone just stating he is not sure I understand? That is just a euphemistic way of s

Re: Nested scopes, and augmented assignment

2006-07-06 Thread Bruno Desthuilliers
Antoon Pardon wrote: > On 2006-07-05, Piet van Oostrum <[EMAIL PROTECTED]> wrote: > >>>Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >> >>>AP> On 2006-07-05, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >>> >Antoon Pardon wrote: >(snip) > >>Well no matter what explanation you

Re: Nested scopes, and augmented assignment

2006-07-06 Thread Antoon Pardon
On 2006-07-05, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: > >>AP> On 2006-07-05, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: Antoon Pardon wrote: (snip) > Well no matter what explanation you give to it, and I understand how it >

Re: Nested scopes, and augmented assignment

2006-07-06 Thread Antoon Pardon
On 2006-07-05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: > >> Python could have chosen an approach with a "nested" keyword > > sure, and Python could also have been invented by aliens, powered by > space potatoes, and been illegal to inhale in Belgium. At one time one could

Re: Nested scopes, and augmented assignment

2006-07-05 Thread Piet van Oostrum
> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >AP> On 2006-07-05, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >>> Antoon Pardon wrote: >>> (snip) Well no matter what explanation you give to it, and I understand how it works, >>> >>> I'm not sure of this. >AP> Should I care abo

Re: Nested scopes, and augmented assignment

2006-07-05 Thread Fredrik Lundh
Antoon Pardon wrote: > Python could have chosen an approach with a "nested" keyword sure, and Python could also have been invented by aliens, powered by space potatoes, and been illegal to inhale in Belgium. have any of your "my mental model of how Python works is more important than how it ac

Re: Nested scopes, and augmented assignment

2006-07-05 Thread Antoon Pardon
On 2006-07-05, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: > (snip) >> Well no matter what explanation you give to it, and I understand how it >> works, > > I'm not sure of this. Should I care about that? >> I keep finding it strange that something like >> >> k = [0]

Re: Nested scopes, and augmented assignment

2006-07-05 Thread Fredrik Lundh
Bruno Desthuilliers wrote: > It's not about "finding a name/identifier", it's about the difference > between (re)binding a name and mutating an object. the difference between binding and performing an operation on an object (mutating or not), in fact. this is Python 101. -- http://mail.pyth

Re: Nested scopes, and augmented assignment

2006-07-05 Thread Bruno Desthuilliers
Antoon Pardon wrote: (snip) > Well no matter what explanation you give to it, and I understand how it > works, I'm not sure of this. > I keep finding it strange that something like > > k = [0] > def f(i): > k[0] += i > f(2) > > works but the following doesn't > > k = 0 > def f(i)

Re: Nested scopes, and augmented assignment

2006-07-05 Thread Antoon Pardon
On 2006-07-04, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > Tim N. van der Leeuw wrote: > >> Hi, >> >> The following might be documented somewhere, but it hit me unexpectedly >> and I couldn't exactly find this in the manual either. >> >&g

Re: Nested scopes, and augmented assignment

2006-07-04 Thread Diez B. Roggisch
Tim N. van der Leeuw wrote: > Hi, > > The following might be documented somewhere, but it hit me unexpectedly > and I couldn't exactly find this in the manual either. > > Problem is, that I cannot use augmented assignment operators in a > nested scope, on variables fro

Nested scopes, and augmented assignment

2006-07-04 Thread Tim N. van der Leeuw
Hi, The following might be documented somewhere, but it hit me unexpectedly and I couldn't exactly find this in the manual either. Problem is, that I cannot use augmented assignment operators in a nested scope, on variables from the outer scope: PythonWin 2.4.3 (#69, Mar 29 2006, 17:35:34)

Re: [Python-Dev] The baby and the bathwater (Re: Scoping, augmented assignment, 'fast locals' - conclusion)

2006-06-19 Thread Boris Borcic
Hello, just a couple points On 6/17/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: [errors involving the shadowing of a variable by another] > > Of course everybody makes errors, but it doesn't follow from this, that > > all make the same errors, or should. > > If I implied that everyone has

Re: [Python-Dev] The baby and the bathwater (Re: Scoping, augmented assignment, 'fast locals' - conclusion)

2006-06-16 Thread Josiah Carlson
n stopped it at "ref to uninitialized local" - or in some other langiage > context ? In the Python case, I can only wonder as to what could make it > memorable - not the debugging, certainly. I wouldn't call the shadowing gratuitous, but it was unfortunate. It happened to me in the c

Re: [Python-Dev] The baby and the bathwater (Re: Scoping, augmented assignment, 'fast locals' - conclusion)

2006-06-16 Thread John Machin
On 17/06/2006 8:00 AM, Boris Borcic wrote: > Josiah Carlson wrote: Please consider abandoning this "conversation". Plan B: Please consider conducting it using private e-mail. Plan C: Please consider conducting it in alt.you.said.I.said.you.said.I.said -- http://mail.python.org/mailman/listinfo/py

Re: [Python-Dev] The baby and the bathwater (Re: Scoping, augmented assignment, 'fast locals' - conclusion)

2006-06-16 Thread Boris Borcic
o, do you mean it happened to you in the Python context so that Python stopped it at "ref to uninitialized local" - or in some other langiage context ? In the Python case, I can only wonder as to what could make it memorable - not the debugging, certainly. In the non-Python case, we

Re: [Python-Dev] The baby and the bathwater (Re: Scoping, augmented assignment, 'fast locals' - conclusion)

2006-06-15 Thread Josiah Carlson
Boris Borcic <[EMAIL PROTECTED]> wrote: > [this is bytes of an oversized put-all-into-it intervention. A possibly > expanded > version will be submitted on clp with local followup before a couple days] > > Josiah Carlson wrote: > > [BB] > >> I'd say a first step in convincing me I am wrong wo

Re: Augmented assignment

2006-02-21 Thread gene tani
Terry Hancock wrote: > On Tue, 21 Feb 2006 10:55:42 +0530 > Suresh Jeevanandam <[EMAIL PROTECTED]> wrote: > Seriously, > I think they are usually equivalent internally, > at least for immutable objects. > yah, but when you do augmented assigns on lists, or mix immutable an dmutable: http://zeph

Re: Augmented assignment

2006-02-21 Thread Terry Hancock
On Tue, 21 Feb 2006 10:55:42 +0530 Suresh Jeevanandam <[EMAIL PROTECTED]> wrote: > Is there any gain in performance because of > augmented assignments. > > x += 1 vs x = x+1 Yep. I perform better when I only type names once. Especially if they are long: length_of_object_I_must

Re: Augmented assignment

2006-02-21 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Terry Reedy wrote: >> Program performance might be noticeable if 'x' is something like a.b.c.d >> that takes some lookup time. But again, I would use the += form for >> readability without testing run time. > > Would x=x + 1 be more

Re: Augmented assignment

2006-02-20 Thread Andrea Griffini
I think it heavily depends on what is "x". If x is bound to a mutable x=x+1 and x+=1 can not only have different speed but indeed can do two very unrelate things (the former probably binding to a new object, the latter probably modifying the same object). For example consider what happens with list

Re: Augmented assignment

2006-02-20 Thread bonono
Terry Reedy wrote: > Program performance might be noticeable if 'x' is something like a.b.c.d > that takes some lookup time. But again, I would use the += form for > readability without testing run time. Would x=x + 1 be more readable, regardless of the background(whether being introduced to the

Re: Augmented assignment

2006-02-20 Thread Suresh Jeevanandam
Thanks Alex. I was not aware of mtimeit. regards, Suresh Alex Martelli wrote: > Suresh Jeevanandam <[EMAIL PROTECTED]> wrote: > >> Hi, >> Is there any gain in performance because of augmented assignments. >> >> x += 1 vs x = x+1 >> >> Or are both of them the same. > > Just *MEASURE*

Re: Augmented assignment

2006-02-20 Thread Terry Reedy
"Suresh Jeevanandam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > Is there any gain in performance because of augmented assignments. > > x += 1 vs x = x+1 > > Or are both of them the same. The main gain is in programmer performance for writing a long name such as number_

Re: Augmented assignment

2006-02-20 Thread Alex Martelli
Suresh Jeevanandam <[EMAIL PROTECTED]> wrote: > Hi, > Is there any gain in performance because of augmented assignments. > > x += 1 vs x = x+1 > > Or are both of them the same. Just *MEASURE*, man! helen:~/apy alex$ python -mtimeit -s'x=0.0' 'x=x+1' 100 loops, best of 3: 0.507

Augmented assignment

2006-02-20 Thread Suresh Jeevanandam
Hi, Is there any gain in performance because of augmented assignments. x += 1 vs x = x+1 Or are both of them the same. regards, Suresh -- http://mail.python.org/mailman/listinfo/python-list

Re: User-defined augmented assignment

2005-10-01 Thread Tom Anderson
On Thu, 29 Sep 2005, Pierre Barbier de Reuille wrote: > a discussion began on python-dev about this. It began by a bug report, > but is shifted and it now belongs to this discussion group. > > The problem I find with augmented assignment is it's too complex, it's > ba

Re: User-defined augmented assignment

2005-09-29 Thread Paddy
I thought along these lines: It is an augmented ASSIGNMENT. (It even has an equals sign in it). tuples are immutable so you should not be able to assign to one of its elements. - So there is no problem for me - I shouldn't be messing with an element of an immutable type! - Cheers,

Re: User-defined augmented assignment

2005-09-29 Thread Pierre Barbier de Reuille
Reinhold Birkenfeld a écrit : > Pierre Barbier de Reuille wrote: > > >>So, what I would suggest is to drop the user-defined augmented >>assignment and to ensure this equivalence : >> >>a X= b <=> a = a X b >> >>with 'X' begin one of th

Re: User-defined augmented assignment

2005-09-29 Thread Reinhold Birkenfeld
Pierre Barbier de Reuille wrote: > So, what I would suggest is to drop the user-defined augmented > assignment and to ensure this equivalence : > > a X= b <=> a = a X b > > with 'X' begin one of the operators. It can be done, but it's unnecessary for mu

User-defined augmented assignment

2005-09-29 Thread Pierre Barbier de Reuille
Hello, a discussion began on python-dev about this. It began by a bug report, but is shifted and it now belongs to this discussion group. The problem I find with augmented assignment is it's too complex, it's badly explained, it's error-prone. And most of all, I don't see