Re: [Python-Dev] 2.5 and beyond

2006-07-11 Thread Gareth McCaughan
> I can say it stronger. Any resemblance between Python and Scheme or > Lisp is purely a coincidence. Neither language is in Python's > ancestry, at least not explicitly; I'd never used or tried to learn > Scheme when I started Python (still haven't) and my Lisp experience > was limited to copying

Re: [Python-Dev] 2.5 and beyond

2006-07-07 Thread Scott Dial
Neal Norwitz wrote: > The current list of serious bugs are in the PEP: > > http://www.python.org/dev/peps/pep-0356/ > > If there are any bugs you think should be considered show stoppers, > mail them to the list and I will update the PEP. http://www.python.org/sf/1519018 I believe this regres

Re: [Python-Dev] 2.5 and beyond

2006-07-07 Thread Neal Norwitz
On 6/30/06, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > > > >There are at least 6 bugs that really, really need to be fixed before > >release. Several of these are AST bugs. Jeremy knows about them and > >plans to fix them once he's back from vacation. Anyone else wanna > >help out? One is

Re: [Python-Dev] 2.5 and beyond

2006-07-06 Thread Thomas Heller
Neal Norwitz schrieb: > On 7/4/06, Thomas Heller <[EMAIL PROTECTED]> wrote: >> >> I would like to ask about the possibility to add some improvements to ctypes >> in Python 2.5, although the feature freeze is now in effect. Hopefully >> former >> third-party libraries can have the freeze relaxed s

Re: [Python-Dev] 2.5 and beyond

2006-07-05 Thread Neal Norwitz
On 7/4/06, Thomas Heller <[EMAIL PROTECTED]> wrote: > > I would like to ask about the possibility to add some improvements to ctypes > in Python 2.5, although the feature freeze is now in effect. Hopefully former > third-party libraries can have the freeze relaxed somewhat;-). Ok, former third-pa

Re: [Python-Dev] 2.5 and beyond

2006-07-04 Thread Fernando Perez
Thomas Heller wrote: > I would like to ask about the possibility to add some improvements to > ctypes > in Python 2.5, although the feature freeze is now in effect. Hopefully > former third-party libraries can have the freeze relaxed somewhat;-). > > I intend to do these changes, the first is a

Re: [Python-Dev] 2.5 and beyond

2006-07-04 Thread Thomas Heller
Neal Norwitz schrieb: > I'm glad to see Anthony ratcheting down. At this point, we need to be > fixing bugs and improving doc. Maybe Anthony and I should have a > contest to see who can revert the most changes. :-) > Neal (and/or Anthony), I would like to ask about the possibility to add some i

Re: [Python-Dev] 2.5 and beyond

2006-07-03 Thread Guido van Rossum
On 7/4/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > One thing to remember is that Python is not Scheme/Lisp. It borrows > some ideas from Scheme/Lisp, I can say it stronger. Any resemblance between Python and Scheme or Lisp is purely a coincidence. Neither language is in Python's ancestry, at

Re: [Python-Dev] 2.5 and beyond

2006-07-03 Thread Josiah Carlson
"Bill Chiles" <[EMAIL PROTECTED]> wrote: > > For Common Lispers and probably Schemers, Python has some surprising > semantics around scope and lifetime extent of variables. Three that > leap out at me are: One thing to remember is that Python is not Scheme/Lisp. It borrows some ideas from Sche

Re: [Python-Dev] 2.5 and beyond

2006-07-03 Thread Bill Chiles
van Rossum; Tim Peters; python-dev@python.org Subject: Re: [Python-Dev] 2.5 and beyond > >>> a = [] > >>> for i in range(10): > ... a.append(lambda: i) > ... > >>> print [x() for x in a] > [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] Isn't this exactly wha

Re: [Python-Dev] 2.5 and beyond

2006-07-02 Thread Greg Ewing
Tim Peters wrote: > Scheme has no loops in Python's sense -- > things like "do" are shorthand for expressing stylized recursion But it does have foreach and map, which are the moral equivalent of Python's for-loops and list comprehensions. The body is a lambda which takes the loop variable as a p

Re: [Python-Dev] 2.5 and beyond

2006-07-02 Thread Greg Ewing
Giovanni Bajo wrote: > I believe that names in > lambdas/nested-functions referring to local names in the outer scope should > really be bound at function definition time No, you don't want that, because it would make functions that call each other very awkward to arrange. > And it's also handy t

Re: [Python-Dev] 2.5 and beyond

2006-07-02 Thread Phillip J. Eby
At 01:58 PM 7/2/2006 +0200, [EMAIL PROTECTED] wrote: >I believe the problem has nothing to do with how many scopes a block/function >definition has, but with what the lambda does with the scope it's given. >Currently it remembers the block and looks up the nescessary variables in it >when it's invo

[Python-Dev] 2.5 and beyond

2006-07-02 Thread jan-python
Hi everyone, Even though I'm new on this list I think I've got something sensible to say on this one. (I've been following this list a bit through the archives) Andrew Koenig wrote: > You seem to be right -- the problem is not that Python is lexically scoped, > but that when you define a variabl

Re: [Python-Dev] 2.5 and beyond

2006-07-01 Thread Tim Peters
[Tim] >> Don't recall what that was, but creating a new scope on each iteration >> sounds hard to explain in Python. [Andrew Koenig] > I don't think it's particularly hard to explain. For example, one way to > explain it is > to say that > > for i in <>: > body > > is equ

Re: [Python-Dev] 2.5 and beyond

2006-07-01 Thread Andrew Koenig
> Don't recall what that was, but creating a new scope on each iteration > sounds hard to explain in Python. I don't think it's particularly hard to explain. For example, one way to explain it is to say that for i in <>: body is equivalent to for <> in <>:

Re: [Python-Dev] 2.5 and beyond

2006-07-01 Thread Giovanni Bajo
Andrew Koenig wrote: > Suppose I write > > x = [] > for i in range(10): > x.append(lambda:i) > print [f() for f in x] > > This example will print [9, 9, 9, 9, 9, 9, 9, 9, 9, 9], which I think > is wildly unintuitive. That is my point: to me, it's counter-intuitive just like the infamous "except N

Re: [Python-Dev] 2.5 and beyond

2006-07-01 Thread Andrew Koenig
> a = [] > for i in range(10): > a.append(lambda: i) > print [x() for x in a] > > [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] Aha! -- Thank you for jogging my memory. You seem to be right -- the problem is not that Python is lexically scoped, but that when you define a variable with =, it leaks out into

Re: [Python-Dev] 2.5 and beyond

2006-07-01 Thread Nick Coghlan
Anthony Baxter wrote: > given the number of people and ways that this can emit a spurious > warning, I think it should be reverted for 2.5. At _best_ we could > maybe have a new -W switch to make it be generated, but this should > be off by default. Last line of warnings.py Copy, paste, s/Pend

Re: [Python-Dev] 2.5 and beyond

2006-07-01 Thread Nick Coghlan
Giovanni Bajo wrote: > Yes but: > a = [] for i in range(10): > ... a.append(lambda: i) > ... print [x() for x in a] > [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] > > This subtle semantic of lambda is quite confusing, and still forces people to > use the "i=i" trick. If you'd like each func

Re: [Python-Dev] 2.5 and beyond

2006-07-01 Thread Tim Peters
[Giovanni Bajo] >> >>> a = [] >> >>> for i in range(10): >> >> ... a.append(lambda: i) >> ... >> >> >>> print [x() for x in a] >> >> [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] >> >> This subtle semantic of lambda is quite confusing, and still forces people to >> use the "i=i" trick. [Greg Ewing] > This ha

Re: [Python-Dev] 2.5 and beyond

2006-07-01 Thread Anthony Baxter
On Saturday 01 July 2006 05:19, Martin v. Löwis wrote: > James Y Knight wrote: > > I just submitted http://python.org/sf/1515169 for the > > ImportWarning issue previously discussed here. IMO it's > > important. > > At the moment (i.e. without an acceptable alternative > implementation) it's primar

Re: [Python-Dev] 2.5 and beyond

2006-07-01 Thread Tim Peters
[Tim Peters] >> Note that this is quite unlike Scheme, in which declaration must >> appear before use (ignoring fancy letrec cases), [Greg Ewing] > I think that's overstating things a bit -- So do I :-), but I don't really care about Scheme here. > mutually recursive functions are quite easy to

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Greg Ewing
Giovanni Bajo wrote: a = [] for i in range(10): > > ... a.append(lambda: i) > ... > print [x() for x in a] > > [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] > > This subtle semantic of lambda is quite confusing, and still forces people to > use the "i=i" trick. This has *nothing* to do with

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Greg Ewing
Tim Peters wrote: > Note that this is quite unlike Scheme, in which declaration must > appear before use (ignoring fancy letrec cases), I think that's overstating things a bit -- mutually recursive functions are quite easy to write in Scheme and don't look at all "fancy" (unless you object for so

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Greg Ewing
Andrew Koenig wrote: > Incidentally, I think that lexical scoping would also deal with the problem > that people often encounter in which they have to write things like "lambda > x=x:" where one would think "lambda x:" would suffice. This is another red herring. Python's problem here is not becau

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Terry Reedy
"Giovanni Bajo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [Giovanni Bajo] >> Yes but: >> > a = [] > for i in range(10): >> ... a.append(lambda: i) >> ... > print [x() for x in a] >> [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] >. Do you agree that it would be ideal if the

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Terry Reedy
"Giovanni Bajo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Yes but: > a = [] for i in range(10): > ... a.append(lambda: i) > ... print [x() for x in a] > [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] > > This subtle semantic of lambda is quite confusing, and still forces >

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Giovanni Bajo
[Giovanni Bajo] > Yes but: > a = [] for i in range(10): > ... a.append(lambda: i) > ... print [x() for x in a] > [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] > > This subtle semantic of lambda is quite confusing, and still forces people to > use the "i=i" trick. [Tim Peters] > So stay away fr

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Bill Janssen
> >>> a = [] > >>> for i in range(10): > ... a.append(lambda: i) > ... > >>> print [x() for x in a] > [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] Isn't this exactly what you'd expect? Maybe I've been writing Python for too long... :-). Bill ___ Python-Dev maili

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Tim Peters
[Giovanni Bajo] > Yes but: > > >>> a = [] > >>> for i in range(10): > ... a.append(lambda: i) > ... > >>> print [x() for x in a] > [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] > > This subtle semantic of lambda is quite confusing, and still forces people to > use the "i=i" trick. So stay away from excruciat

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Giovanni Bajo
Tim Peters <[EMAIL PROTECTED]> wrote: >> ... >> Incidentally, I think that lexical scoping would also deal with the >> problem >> that people often encounter in which they have to write things like >> "lambda >> x=x:" where one would think "lambda x:" would suffice. > > They _shouldn't_ encounter

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Tim Peters
[Andrew Koenig] > Almost. What I really want is for it to be possible to determine the > binding of every name by inspecting the source text of the program. Right > now, it is often possible to do so, but sometimes it isn't. Local names are always determined at compile-time in Python. What you

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Ka-Ping Yee
On Fri, 30 Jun 2006, Andrew Koenig wrote: > The fundamental principle is that the binding of every name is determined > during compilation, not during execution. This property does not quite > apply to Python at present. I think this property does apply. In your example: > def g(): >

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Guido van Rossum
On 6/30/06, Andrew Koenig <[EMAIL PROTECTED]> wrote: > > I read "a la Scheme" here as "actually nothing like Scheme, except I > > want a non-tricky way to rebind a name from an enclosing scope within > > an enclosed scope". > > Almost. What I really want is for it to be possible to determine the >

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Tim Peters
[Andrew Koenig] > ... > Incidentally, I think that lexical scoping would also deal with the problem > that people often encounter in which they have to write things like "lambda > x=x:" where one would think "lambda x:" would suffice. They _shouldn't_ encounter that at all anymore. For example,

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Phillip J. Eby
At 07:04 PM 6/30/2006 -0400, Andrew Koenig wrote: >However, if I write > > def g(): > return x > x = 42 > g() > >the result is 42. With lexical scoping, I believe it should be undefined. > >The reason is that when the compiler encounters the definition of g,

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Andrew Koenig
> I read "a la Scheme" here as "actually nothing like Scheme, except I > want a non-tricky way to rebind a name from an enclosing scope within > an enclosed scope". Almost. What I really want is for it to be possible to determine the binding of every name by inspecting the source text of the prog

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Andrew Koenig
> That sounds like a bug, not a feature. It's frequently useful to have > forward references in function bodies to names that are not yet globally > bound, e.g. for classes, or mutually-recursive functions. The trouble is that you don't necessarily know in what scope they will be defined, so I t

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Tim Peters
[Andrew Koenig] >>> I saw messages out of sequence and did not realize that this would be a >>> change in behavior from 2.4. Sigh. [Ka-Ping Yee] >> Yes, this is not a good time to change it. >>> I hope Py3000 has lexical scoping a la Scheme... >> Me too -- that would be really nice. [Guido] >

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Scott Dial
Guido van Rossum wrote: > On 6/30/06, Ka-Ping Yee <[EMAIL PROTECTED]> wrote: >> On Fri, 30 Jun 2006, Andrew Koenig wrote: >>> I hope Py3000 has lexical scoping a la Scheme... >> Me too -- that would be really nice. > > That's not a very constructive proposal (especially since I don't know > Scheme

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Andrew Koenig
> That's not a very constructive proposal (especially since I don't know > Scheme). Perhaps you could elaborate on what needs to change? The fundamental principle is that the binding of every name is determined during compilation, not during execution. This property does not quite apply to Python

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Guido van Rossum
On 6/30/06, Ka-Ping Yee <[EMAIL PROTECTED]> wrote: > On Fri, 30 Jun 2006, Andrew Koenig wrote: > > I saw messages out of sequence and did not realize that this would be a > > change in behavior from 2.4. Sigh. > > Yes, this is not a good time to change it. > > > I hope Py3000 has lexical scoping a

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Ka-Ping Yee
On Fri, 30 Jun 2006, Andrew Koenig wrote: > I saw messages out of sequence and did not realize that this would be a > change in behavior from 2.4. Sigh. Yes, this is not a good time to change it. > I hope Py3000 has lexical scoping a la Scheme... Me too -- that would be really nice. -- ?!ng _

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Martin v. Löwis
James Y Knight wrote: > On Jun 30, 2006, at 3:05 AM, Neal Norwitz wrote: >> If there are any bugs you think should be considered show stoppers, >> mail them to the list and I will update the PEP. > > I just submitted http://python.org/sf/1515169 for the ImportWarning > issue previously discussed

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Martin v. Löwis
[EMAIL PROTECTED] wrote: > Ping> The question is, what behaviour is preferable for this code: > > Ping> g = 1 > Ping> def f(): > Ping> g += 1 > > Ping> f() > > If you treat "g += 1" as "g = g + 1" then it should create a local variable > with a value of 2.

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Andrew Koenig
> I think it should increment (i.e. rebind) g, for the same reason that > > g = [1] > def f(): > g[0] += 1 > f() > > rebinds g[0]. I saw messages out of sequence and did not realize that this would be a change in behavior from 2.4. Sigh. I hope Py3000 has lexica

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Andrew Koenig
> The question is, what behaviour is preferable for this code: > > g = 1 > def f(): > g += 1 > > f() > > Should this raise an UnboundLocalError or should it increment g? I think it should increment (i.e. rebind) g, for the same reason that g = [1] def f():

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread James Y Knight
On Jun 30, 2006, at 3:05 AM, Neal Norwitz wrote: > If there are any bugs you think should be considered show stoppers, > mail them to the list and I will update the PEP. I just submitted http://python.org/sf/1515169 for the ImportWarning issue previously discussed here. IMO it's important. Jame

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Jean-Paul Calderone
On Fri, 30 Jun 2006 00:05:10 -0700, Neal Norwitz <[EMAIL PROTECTED]> wrote: >I'm glad to see Anthony ratcheting down. At this point, we need to be >fixing bugs and improving doc. Maybe Anthony and I should have a >contest to see who can revert the most changes. :-) > >There are at least 6 bugs th

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread skip
Ping> The question is, what behaviour is preferable for this code: Ping> g = 1 Ping> def f(): Ping> g += 1 Ping> f() If you treat "g += 1" as "g = g + 1" then it should create a local variable with a value of 2. There being no global statement in f() it

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Michael Hudson
Ka-Ping Yee <[EMAIL PROTECTED]> writes: > On Fri, 30 Jun 2006, Neal Norwitz wrote: >> The current list of serious bugs are in the PEP: >> >> http://www.python.org/dev/peps/pep-0356/ > > Among them is this one: > > Incorrect LOAD/STORE_GLOBAL generation > http://python.org/sf/1501934 > >

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Tim Peters
[Ka-Ping Yee, on http://www.python.org/dev/peps/pep-0356/ ] > Among them is this one: > > Incorrect LOAD/STORE_GLOBAL generation > http://python.org/sf/1501934 > > The question is, what behaviour is preferable for this code: > > g = 1 > def f(): > g += 1 > > f() > > Sh

Re: [Python-Dev] 2.5 and beyond

2006-06-30 Thread Ka-Ping Yee
On Fri, 30 Jun 2006, Neal Norwitz wrote: > The current list of serious bugs are in the PEP: > > http://www.python.org/dev/peps/pep-0356/ Among them is this one: Incorrect LOAD/STORE_GLOBAL generation http://python.org/sf/1501934 The question is, what behaviour is preferable for this co

[Python-Dev] 2.5 and beyond

2006-06-30 Thread Neal Norwitz
I'm glad to see Anthony ratcheting down. At this point, we need to be fixing bugs and improving doc. Maybe Anthony and I should have a contest to see who can revert the most changes. :-) There are at least 6 bugs that really, really need to be fixed before release. Several of these are AST bugs