Re: [Python-Dev] 2.5 and beyond

2006-07-01 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 because its

Re: [Python-Dev] Lexical scoping in Python 3k

2006-07-01 Thread Greg Ewing
Josiah Carlson wrote: What I asked before, and what I'd like to ask again, is if there are any _nontrivial uses_ of lexically nested scopes which are made cumbersome by our inability to write to parent scopes. The trouble with taking that position is that the very cases which would benefit

Re: [Python-Dev] 2.5 and beyond

2006-07-01 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 the semantics of

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 write

Re: [Python-Dev] ImportWarning flood

2006-07-01 Thread Anthony Baxter
On Saturday 01 July 2006 12:55, Guido van Rossum wrote: It's up to the release manager now to decide whether the pitchforks at Google or the pitchforks in the larger Python community are sharper. ;-) At this point, I think removing the warning code is the prudent course. If someone wanted to

Re: [Python-Dev] ImportWarning flood

2006-07-01 Thread Nick Coghlan
Guido van Rossum wrote: It's up to the release manager now to decide whether the pitchforks at Google or the pitchforks in the larger Python community are sharper. ;-) --Guido (ducks) I vaguely recall one of the reasons we went with the warning approach was to find out whether or not

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

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 has *nothing* to do with the

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 function instance to have

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,

Re: [Python-Dev] Cleanup of test harness for Python

2006-07-01 Thread Armin Rigo
Hi all, On Fri, Jun 30, 2006 at 10:05:14AM -0400, Frank Wierzbicki wrote: some checks for CPython internal tests that should be excluded from Jython I know Frank already knows about this, but I take the occasion to remind us that

Re: [Python-Dev] sys.settrace() in Python 2.3 vs. 2.4

2006-07-01 Thread Armin Rigo
Hi Josiah, On Fri, Jun 30, 2006 at 01:27:24PM -0700, Josiah Carlson wrote: I'll just have to gracefully degrade functionality for older Pythons. More precisely, the bug shows up because in while 1: pass the current line remains on the 'pass' forever. It works for a loop like that:

Re: [Python-Dev] Lexical scoping in Python 3k

2006-07-01 Thread Josiah Carlson
Greg Ewing [EMAIL PROTECTED] wrote: Josiah Carlson wrote: What I asked before, and what I'd like to ask again, is if there are any _nontrivial uses_ of lexically nested scopes which are made cumbersome by our inability to write to parent scopes. The trouble with taking that position

Re: [Python-Dev] Bug in stringobject?

2006-07-01 Thread Georg Brandl
Georg Brandl wrote: In string_replace, there is if (PyString_Check(from)) { /* Can this be made a '!check' after the Unicode check? */ } #ifdef Py_USING_UNICODE if (PyUnicode_Check(from)) return PyUnicode_Replace((PyObject *)self,

Re: [Python-Dev] Bug in stringobject?

2006-07-01 Thread Fredrik Lundh
Georg Brandl wrote: Can this be correct if from or to isn't a string object, but a char buffer compatible object? May I note that this is still unresolved? I can submit a bug report and add it to PEP 356, too... it's already on my todo list, but that list is full of stuff, so having it on

Re: [Python-Dev] Bug in stringobject?

2006-07-01 Thread Georg Brandl
Fredrik Lundh wrote: Georg Brandl wrote: Can this be correct if from or to isn't a string object, but a char buffer compatible object? May I note that this is still unresolved? I can submit a bug report and add it to PEP 356, too... it's already on my todo list, but that list is full

[Python-Dev] weakattr

2006-07-01 Thread tomer filiba
weakattr (weak attributes) are attributes that are weakly referencedby their containing object. they are very useful for cyclic references --an object that holds a reference to itself. when a cyclic reference is found by the GC, the memory may be freed, but __del__ is not called, because it's

Re: [Python-Dev] Lexical scoping in Python 3k

2006-07-01 Thread Neil Schemenauer
Ka-Ping Yee [EMAIL PROTECTED] wrote: Most other languages that support lexical scoping (including Scheme, JavaScript, Ruby, Perl, E, Java, Smalltalk) provide a uniform way to read and write to scopes at all levels. This is done by letting programmers specify the scope in which they want a

Re: [Python-Dev] zlib module build failure on Mac OSX 10.4.7

2006-07-01 Thread Ronald Oussoren
On Jul 1, 2006, at 5:32 AM, [EMAIL PROTECTED] wrote: Just upgraded my Mac to OSX 10.4.7 yesterday. svn up'd Python trunk, then make clean ; configure ; make and I see that building the zlib module fails: gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno- fused-madd

Re: [Python-Dev] Lexical scoping in Python 3k

2006-07-01 Thread Almann T. Goo
On 7/1/06, Josiah Carlson [EMAIL PROTECTED] wrote: There's one very simple way we could do this in Py3k without requiring any new syntax or keywords: just redefine the meaning of global to mean not local.I would probably be a solid -0 on such a proposal; I still don't think it's really necessary,

Re: [Python-Dev] zlib module build failure on Mac OSX 10.4.7

2006-07-01 Thread skip
Ronald Are you sure you're building on a 10.4 box? Both the Ronald macosx-10.3 thingy and lack of inflateCopy seem to indicate that Ronald you're running on 10.3. Well, yeah, pretty sure. Let's see. The box with the disk says Mac OS X Tiger - Version 10.4 on the spine. The About

Re: [Python-Dev] ImportWarning flood

2006-07-01 Thread Sergey A. Lipnevich
All, I tried to implement Jean-Paul Calderone's idea for the following patch, plagiarizing Ralf W. Grosse-Kunstleve's error text. It delays import warning until end of search for modules, but remembers how many potential modules (candidates without __init__.py) it didn't import. I didn't really

Re: [Python-Dev] ImportWarning flood

2006-07-01 Thread Aahz
On Sat, Jul 01, 2006, Sergey A. Lipnevich wrote: Please let me know if this would work and if anything needs to be done for this patch to be accepted. The first thing you need to do for ANY patch to be considered is to post it so SourceForge (or at least post to python-dev explaining that

Re: [Python-Dev] ImportWarning flood

2006-07-01 Thread Martin v. Löwis
Sergey A. Lipnevich wrote: I tried to implement Jean-Paul Calderone's idea for the following patch, plagiarizing Ralf W. Grosse-Kunstleve's error text. It delays import warning until end of search for modules, but remembers how many potential modules (candidates without __init__.py) it didn't

Re: [Python-Dev] ImportWarning flood

2006-07-01 Thread Sergey A. Lipnevich
Martin v. Löwis wrote: Sergey A. Lipnevich wrote: I tried to implement Jean-Paul Calderone's idea for the following patch, plagiarizing Ralf W. Grosse-Kunstleve's error text. It delays import ... Please notice that there is also python.org/sf/1515361 I had no time to compare this with your

Re: [Python-Dev] Lexical scoping in Python 3k

2006-07-01 Thread Simon Percivall
What about doing something similar to how import was changed? .a = 5 # this scope (self might be too magical ..a = 3 # up one scope ...a # up three Of course, this looks ... perhaps a bit strange. Also, counting is a bother. //Simon ___ Python-Dev

Re: [Python-Dev] zlib module build failure on Mac OSX 10.4.7

2006-07-01 Thread Martin v. Löwis
Ronald Oussoren wrote: What I don't understand yet is why your copy of libz doesn't have inflateCopy. What I don't understand is that configure does not detect that. Regards, Martin ___ Python-Dev mailing list Python-Dev@python.org

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 the

Re: [Python-Dev] Lexical scoping in Python 3k

2006-07-01 Thread Andrew Koenig
What about doing something similar to how import was changed? .a = 5 # this scope (self might be too magical ..a = 3 # up one scope ...a # up three Of course, this looks ... perhaps a bit strange. Also, counting is a bother. I'd rather see a simpler rule: = never defines a variable in a

Re: [Python-Dev] zlib module build failure on Mac OSX 10.4.7

2006-07-01 Thread Ronald Oussoren
On Jul 1, 2006, at 8:46 PM, Martin v. Löwis wrote: Ronald Oussoren wrote: What I don't understand yet is why your copy of libz doesn't have inflateCopy. What I don't understand is that configure does not detect that. You may be onto something there. Skip, do you have another copy of

Re: [Python-Dev] zlib module build failure on Mac OSX 10.4.7

2006-07-01 Thread Bob Ippolito
On Jul 1, 2006, at 10:45 AM, Ronald Oussoren wrote: On Jul 1, 2006, at 6:57 PM, [EMAIL PROTECTED] wrote: Ronald Are you sure you're building on a 10.4 box? Both the Ronald macosx-10.3 thingy and lack of inflateCopy seem to indicate that Ronald you're running on 10.3.

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

Re: [Python-Dev] Empty Subscript PEP on Wiki - keep or toss?

2006-07-01 Thread Noam Raphael
Hello, I posted it as a pre-PEP, in the hope that it may become a PEP and be accepted. As it happened, Guido said no at the end, so I stopped pushing the subject. I think that the main reason for the no was that my use case wasn't convincing enough - the objections were that this wasn't useful

Re: [Python-Dev] doc for new restricted execution design for Python

2006-07-01 Thread Samuele Pedroni
Brett Cannon wrote: I don't know how JavaScript is doing it yet. The critical thing for me for this month was trying to come up with a security model. And if you don't think it is going to scale, how do you think it should be done? if I remember correctly, the boundary/granularity of

Re: [Python-Dev] For sandboxing: alternative to crippling file()

2006-07-01 Thread Brett Cannon
On 6/30/06, Greg Ewing [EMAIL PROTECTED] wrote: Brett Cannon wrote: 1) Is removing 'file' from the builtins dict in PyInterpreterState (and maybe some other things) going to be safe enough to sufficiently hide 'file' confidently (short of someone being stupid in their C extension module and

Re: [Python-Dev] zlib module build failure on Mac OSX 10.4.7

2006-07-01 Thread skip
Ronald What does /usr/lib/libz.dylib point to on your system? % cd /usr/lib % ls -l libz.* lrwxr-xr-x 1 root wheel 12 Feb 12 00:32 libz.1.1.3.dylib - libz.1.dylib -rwxr-xr-x 1 root wheel 72588 Jun 29 18:36 libz.1.2.3.dylib lrwxr-xr-x 1 root wheel 16

Re: [Python-Dev] Empty Subscript PEP on Wiki - keep or toss?

2006-07-01 Thread skip
Noam If the only result of me posting it as a PEP is a final rejected Noam status that will prevent any chance of that happening, I don't Noam think I'll bother to make it a PEP. If it's not the case, then Noam I'll make it a PEP and post it. Even if it's ultimately rejected, it

Re: [Python-Dev] Lexical scoping in Python 3k

2006-07-01 Thread Ka-Ping Yee
On Sat, 1 Jul 2006, Greg Ewing wrote: I don't disagree with anything you said, but I think it would be a good idea to avoid using phrases like proper lexical scopes, which is likely to set people off on a tangent. The issue isn't lexicality, it's writeability. Fully functional lexical scopes,

Re: [Python-Dev] Lexical scoping in Python 3k

2006-07-01 Thread Andrew Koenig
Fully functional lexical scopes, then? Fine-grained scopes? ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

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 stuff: body is equivalent to for hiddenvar in

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 stuff: body is equivalent

Re: [Python-Dev] how long to wait for expat to incorpo rate a fix to prevent a crasher?

2006-07-01 Thread Fred L. Drake, Jr.
On Friday 30 June 2006 16:03, Martin v. Löwis wrote: If you have a patch, you should commit it to our copy. Make sure you activate the test case, so that somebody incorporating the next Expat release doesn't mistakenly roll back your change. A modified version of Brett's patch has been

Re: [Python-Dev] Lexical scoping in Python 3k

2006-07-01 Thread Nick Coghlan
Neil Schemenauer wrote: The := would assign but not declare a variable in the current scope. There are other benefits to such a statement, too, since we can make it similar to other augmented assignments by letting the object being assigned to interfere with the process. a := 2 could

Re: [Python-Dev] sys.settrace() in Python 2.3 vs. 2.4

2006-07-01 Thread Josiah Carlson
Armin Rigo [EMAIL PROTECTED] wrote: Hi Josiah, On Fri, Jun 30, 2006 at 01:27:24PM -0700, Josiah Carlson wrote: I'll just have to gracefully degrade functionality for older Pythons. More precisely, the bug shows up because in while 1: pass the current line remains on the

Re: [Python-Dev] weakattr

2006-07-01 Thread Josiah Carlson
tomer filiba [EMAIL PROTECTED] wrote: weakattr (weak attributes) are attributes that are weakly referenced by their containing object. they are very useful for cyclic references -- an object that holds a reference to itself. I like the added functionality offered with weakattrs as defined.

Re: [Python-Dev] More Switch: Explicit freezing

2006-07-01 Thread Josiah Carlson
Talin [EMAIL PROTECTED] wrote: Here's another stab at the explicit freezing school of thought on the switch semantics. The idea is to borrow the freeze protocol and apply it to functions. -1 . Freezing was previously questionably useful in the realm of general data structures. Using