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. >> >> Problem is, that I cannot use augmented assignment operat

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 from the outer scope: > Is

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) [MSC