[Python-Dev] rich comparisions and old-style classes

2006-04-30 Thread Fredrik Lundh
trying to come up with a more concise description of the rich comparision machinery for pyref.infogami.com, I stumbled upon an oddity that I cannot really explain: in the attached example below, why is the rich comparision machinery doing *four* attempts to use __eq__ in the old- class case? /F

[Python-Dev] PEP 3101: Advanced String Formatting

2006-04-30 Thread Talin
PEP: 3101 Title: Advanced String Formatting Version: $Revision$ Last-Modified: $Date$ Author: Talin talin at acm.org Status: Draft Type: Standards Content-Type: text/plain Created: 16-Apr-2006 Python-Version: 3.0 Post-History: Abstract This PEP proposes a new system for built-in string

Re: [Python-Dev] draft of externally maintained packages PEP

2006-04-30 Thread Fredrik Lundh
Brett Cannon wrote: ElementTree --- - Web page http://effbot.org/zone/element-index.htm - Standard library name xml.etree - Contact person Fredrik Lundh - Synchronisation history * 1.2.6 (2.5) xml.etree contains components from both ElementTree and and

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Martin v. Löwis
Terry Reedy wrote: Now, suppose you wanted to have 'key' be a keyword-only argument. Why? Why not let the user type the additional argument(s) without the parameter name? Are you asking why that feature (keyword-only arguments) is desirable? That's the whole point of the PEP. Or are

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Thomas Wouters
On 4/30/06, Steven Bethard [EMAIL PROTECTED] wrote: On 4/29/06, Talin [EMAIL PROTECTED] wrote:This PEP proposes a change to the way that function arguments areassigned to named parameter slots.In particular, it enables the declaration of keyword-only arguments: arguments that can onlybe supplied

Re: [Python-Dev] methods on the bytes object (was: Crazy idea for str.join)

2006-04-30 Thread Josiah Carlson
Guido van Rossum [EMAIL PROTECTED] wrote: On 4/29/06, Josiah Carlson [EMAIL PROTECTED] wrote: I understand the underlying implementation of str.join can be a bit convoluted (with the auto-promotion to unicode and all), but I don't suppose there is any chance to get str.join to support

Re: [Python-Dev] methods on the bytes object

2006-04-30 Thread Martin v. Löwis
Josiah Carlson wrote: Specifically in the case of bytes.join(), the current common use-case of literal.join(...) would become something similar to bytes(literal).join(...), unless bytes objects got a syntax... Or maybe I'm missing something? I think what you are missing is that algorithms

[Python-Dev] Problem with inspect and PEP 302

2006-04-30 Thread Georg Brandl
Recently, the inspect module was updated to conform with PEP 302. Now this is broken: import inspect inspect.stack() The traceback shows clearly what's going on. However, I don't know how to resolve the problem. Georg ___ Python-Dev mailing list

Re: [Python-Dev] rich comparisions and old-style classes

2006-04-30 Thread Armin Rigo
Hi Fredrik, On Sun, Apr 30, 2006 at 08:13:40AM +0200, Fredrik Lundh wrote: trying to come up with a more concise description of the rich comparision machinery for pyref.infogami.com, That's quite optimistic. It's a known dark area. I stumbled upon an oddity that I cannot really explain:

Re: [Python-Dev] rich comparisions and old-style classes

2006-04-30 Thread Michael Foord
Armin Rigo wrote: Hi Fredrik, On Sun, Apr 30, 2006 at 08:13:40AM +0200, Fredrik Lundh wrote: trying to come up with a more concise description of the rich comparision machinery for pyref.infogami.com, That's quite optimistic. It's a known dark area. I stumbled upon an

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Nick Coghlan
Terry Reedy wrote: Talin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Now, suppose you wanted to have 'key' be a keyword-only argument. Why? Why not let the user type the additional argument(s) without the parameter name? Because for some functions (e.g. min()/max()) you

Re: [Python-Dev] PEP 3101: Advanced String Formatting

2006-04-30 Thread Aahz
First of all, I recommend that you post this to comp.lang.python. This is the kind of PEP where wide community involvement is essential to success; be prepared for massive revision. (My point about massive revision would be true regardless of how much consensus has been reached on python-dev --

[Python-Dev] More on contextlib - adding back a contextmanager decorator

2006-04-30 Thread Nick Coghlan
A few things from the pre-alpha2 context management terminology review have had a chance to run around in the back of my head for a while now, and I'd like to return to a topic Paul Moore brought up during that discussion. Paul had a feeling there should be two generator decorators in

[Python-Dev] Adding functools.decorator

2006-04-30 Thread Nick Coghlan
Collin Winters has done the work necessary to rename PEP 309's functional module to functools and posted the details to SF [1]. I'd like to take that patch, tweak it so the C module is built as _functools rather than functools, and then add a functools.py consisting of: from _functools import

[Python-Dev] PyThreadState_SetAsyncExc and native extensions

2006-04-30 Thread Gabriel Becedillas
Does anyone know if PyThreadState_SetAsyncExc stops a thread while its inside a native extension ? I'm trying to stop a testing script that boils down to this: while True: print aaa native_extension_call() print bbb Using PyThreadState_SetAsyncExc the module doesn't stop but if I

[Python-Dev] __getslice__ usage in sre_parse

2006-04-30 Thread Sanghyeon Seo
Hello, Python language reference 3.3.6 deprecates __getslice__. I think it's okay that UserList.py has it, but sre_parse shouldn't use it, no? __getslice__ is not implemented in IronPython and this breaks usage of _sre.py, a pure-Python implementation of _sre, on IronPython:

[Python-Dev] elimination of scope bleeding of iteration variables

2006-04-30 Thread Ben Wing
apologies if this has been brought up on python-dev already. a suggestion i have, perhaps for python 3.0 since it may break some code (but imo it could go into 2.6 or 2.7 because the likely breakage would be very small, see below), is the elimination of the misfeature whereby the iteration

Re: [Python-Dev] elimination of scope bleeding of iteration variables

2006-04-30 Thread Nick Coghlan
Ben Wing wrote: apologies if this has been brought up on python-dev already. a suggestion i have, perhaps for python 3.0 since it may break some code (but imo it could go into 2.6 or 2.7 because the likely breakage would be very small, see below), is the elimination of the misfeature

Re: [Python-Dev] Adding functools.decorator

2006-04-30 Thread Simon Belak
Nick Coghlan wrote: Some details that are up for discussion: - which of a function's special attributes should be copied/updated? - should the __decorates__ and __decorator__ attributes be added? If people are happy with this idea, I can make sure it happens before alpha 3. What

Re: [Python-Dev] methods on the bytes object

2006-04-30 Thread Guido van Rossum
On 4/30/06, Martin v. Löwis [EMAIL PROTECTED] wrote: Josiah Carlson wrote: Specifically in the case of bytes.join(), the current common use-case of literal.join(...) would become something similar to bytes(literal).join(...), unless bytes objects got a syntax... Or maybe I'm missing

Re: [Python-Dev] Adding functools.decorator

2006-04-30 Thread Georg Brandl
Nick Coghlan wrote: Collin Winters has done the work necessary to rename PEP 309's functional module to functools and posted the details to SF [1]. I'd like to take that patch, tweak it so the C module is built as _functools rather than functools, and then add a functools.py consisting of:

Re: [Python-Dev] __getslice__ usage in sre_parse

2006-04-30 Thread Guido van Rossum
On 4/28/06, Sanghyeon Seo [EMAIL PROTECTED] wrote: Hello, Python language reference 3.3.6 deprecates __getslice__. I think it's okay that UserList.py has it, but sre_parse shouldn't use it, no? Well, as long as the deprecated code isn't removed, there's no reason why other library code

Re: [Python-Dev] PyThreadState_SetAsyncExc and native extensions

2006-04-30 Thread Aahz
On Fri, Apr 28, 2006, Gabriel Becedillas wrote: Does anyone know if PyThreadState_SetAsyncExc stops a thread while its inside a native extension ? Please take this question to comp.lang.python; python-dev is for discussion about changes to the Python interpreter/language, not for questions

Re: [Python-Dev] methods on the bytes object

2006-04-30 Thread Phillip J. Eby
At 08:22 AM 4/30/2006 -0700, Guido van Rossum wrote: Still, I expect that having a bunch of string-ish methods on bytes arrays would be convenient for certain types of data handling. Of course, only those methods that don't care about character types would be added, but that's a long list:

Re: [Python-Dev] Adding functools.decorator

2006-04-30 Thread Guido van Rossum
On 4/30/06, Georg Brandl [EMAIL PROTECTED] wrote: Nick Coghlan wrote: Collin Winters has done the work necessary to rename PEP 309's functional module to functools and posted the details to SF [1]. I'd like to take that patch, tweak it so the C module is built as _functools rather than

Re: [Python-Dev] More on contextlib - adding back a contextmanager decorator

2006-04-30 Thread Guido van Rossum
On 4/30/06, Nick Coghlan [EMAIL PROTECTED] wrote: A few things from the pre-alpha2 context management terminology review have had a chance to run around in the back of my head for a while now, and I'd like to return to a topic Paul Moore brought up during that discussion. I believe the context

Re: [Python-Dev] Adding functools.decorator

2006-04-30 Thread Georg Brandl
Guido van Rossum wrote: On 4/30/06, Georg Brandl [EMAIL PROTECTED] wrote: Nick Coghlan wrote: Collin Winters has done the work necessary to rename PEP 309's functional module to functools and posted the details to SF [1]. I'd like to take that patch, tweak it so the C module is built as

Re: [Python-Dev] More on contextlib - adding back a contextmanagerdecorator

2006-04-30 Thread Fredrik Lundh
Guido van Rossum wrote: I believe the context API design has gotten totally out of hand. I have a counter-proposal: let's drop __context__. Heh. I was about to pull out the if the implementation is hard to explain, it's a bad idea (and bad ideas shouldn't go into 2.X) rule last week in

Re: [Python-Dev] [Python-3000] in-out parameters

2006-04-30 Thread Edward Loper
Rudy Rudolph wrote: 2) pass-by-reference: def f(wrappedParam): wrappedParam[0] += 5 # ugh return this is my result # call it x = 2 result = f([x]) # also ugly, but x is now 7 This example is broken; here's what you get when you run it: def

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Zachary Pincus
Some thoughts from a lurker, largely concerning syntax; discount as you wish. First: Keyword-only arguments are not required to have a default value. Since Python requires that all arguments be bound to a value, and since the only way to bind a value to a keyword-only argument

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Georg Brandl
Zachary Pincus wrote: Some thoughts from a lurker, largely concerning syntax; discount as you wish. First: Keyword-only arguments are not required to have a default value. Since Python requires that all arguments be bound to a value, and since the only way to bind a value

Re: [Python-Dev] PEP 3101: Advanced String Formatting

2006-04-30 Thread Zachary Pincus
I'm not sure about introducing a special syntax for accessing dictionary entries, array elements and/or object attributes *within a string formatter*... much less an overloaded one that differs from how these elements are accessed in regular python. Compound names are a sequence of

Re: [Python-Dev] PEP 3101: Advanced String Formatting

2006-04-30 Thread Bill Janssen
For most built-in types, the conversion specifiers will be the same or similar to the existing conversion specifiers used with the '%' operator. Thus, instead of '%02.2x, you will say '{0:2.2x}'. Don't you mean, {0:02.2x}? Bill

Re: [Python-Dev] PEP 3101: Advanced String Formatting

2006-04-30 Thread Georg Brandl
Zachary Pincus wrote: I'm not sure about introducing a special syntax for accessing dictionary entries, array elements and/or object attributes *within a string formatter*... much less an overloaded one that differs from how these elements are accessed in regular python. Yes, I also

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Joe Smith
Talin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Abstract This PEP proposes a change to the way that function arguments are assigned to named parameter slots. In particular, it enables the declaration of keyword-only arguments: arguments that can only be

Re: [Python-Dev] methods on the bytes object

2006-04-30 Thread Josiah Carlson
Martin v. Löwis [EMAIL PROTECTED] wrote: Josiah Carlson wrote: Specifically in the case of bytes.join(), the current common use-case of literal.join(...) would become something similar to bytes(literal).join(...), unless bytes objects got a syntax... Or maybe I'm missing something? I

Re: [Python-Dev] methods on the bytes object

2006-04-30 Thread Martin v. Löwis
Josiah Carlson wrote: I think what you are missing is that algorithms that currently operate on byte strings should be reformulated to operate on character strings, not reformulated to operate on bytes objects. By character strings can I assume you mean unicode strings which contain data,

Re: [Python-Dev] PEP 3101: Advanced String Formatting

2006-04-30 Thread Martin v. Löwis
Aahz wrote: First of all, I recommend that you post this to comp.lang.python. This is the kind of PEP where wide community involvement is essential to success; be prepared for massive revision. Actually, *all* PEPs should be posted to c.l.p at some point; the PEP author is responsible for

Re: [Python-Dev] More on contextlib - adding back a contextmanager decorator

2006-04-30 Thread Phillip J. Eby
At 09:53 AM 4/30/2006 -0700, Guido van Rossum wrote: I have a counter-proposal: let's drop __context__. Nearly all use cases have __context__ return self. In the remaining cases, would it really be such a big deal to let the user make an explicit call to some appropriately named method? The only

Re: [Python-Dev] Problem with inspect and PEP 302

2006-04-30 Thread Phillip J. Eby
At 12:13 PM 4/30/2006 +0200, Georg Brandl wrote: Recently, the inspect module was updated to conform with PEP 302. Now this is broken: import inspect inspect.stack() The traceback shows clearly what's going on. However, I don't know how to resolve the problem. The problem as that 'string'

Re: [Python-Dev] Tkinter lockups.

2006-04-30 Thread Martin v. Löwis
Jeff Epler wrote: However, on this system, I couldn't recreate the problem you reported with either the using _tkinter directly instructions, or using this C test program: #include tcl.h #include tk.h int main(void) { Tcl_Interp *trp; unsetenv(DISPLAY); trp =

[Python-Dev] socket module recvmsg/sendmsg

2006-04-30 Thread Heiko Wundram
Hi all! I've implemented recvmsg and sendmsg for the socket module in my private Python tree for communication between two forked processes, which are essentially wrappers for proper handling of SCM_RIGHTS and SCM_CREDENTIALS Unix-Domain-Socket messages (which are the two types of messages

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Talin
Thomas Wouters thomas at python.org writes: Pfft, implementation is easy. I have the impression Talin wants to implement it himself, but even if he doesn't, I'm sure I'll have a free week somewhere in the next year and a half in which I can implement it :) It's not that hard a problem, it just

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Talin
Zachary Pincus zpincus at stanford.edu writes: That seems a bit odd, as my natural expectation wouldn't be to see kw1 ands kw2 as required, no-default keyword args, but as misplaced positional args. Perhaps this might be a little better? def foo(*args, kw1=, kw2=): I'm rather not

Re: [Python-Dev] PEP 3101: Advanced String Formatting

2006-04-30 Thread Talin
Zachary Pincus wrote: I'm not sure about introducing a special syntax for accessing dictionary entries, array elements and/or object attributes *within a string formatter*... much less an overloaded one that differs from how these elements are accessed in regular python.

Re: [Python-Dev] Adding functools.decorator

2006-04-30 Thread Brett Cannon
On 4/30/06, Guido van Rossum [EMAIL PROTECTED] wrote: On 4/30/06, Georg Brandl [EMAIL PROTECTED] wrote: Nick Coghlan wrote: Collin Winters has done the work necessary to rename PEP 309's functional module to functools and posted the details to SF [1]. I'd like to take that patch,

Re: [Python-Dev] More on contextlib - adding back a contextmanager decorator

2006-04-30 Thread Brett Cannon
On 4/30/06, Guido van Rossum [EMAIL PROTECTED] wrote: On 4/30/06, Nick Coghlan [EMAIL PROTECTED] wrote: A few things from the pre-alpha2 context management terminology review have had a chance to run around in the back of my head for a while now, and I'd like to return to a topic Paul Moore

Re: [Python-Dev] PEP 3101: Advanced String Formatting

2006-04-30 Thread Terry Reedy
Talin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Compound names are a sequence of simple names seperated by separated The string and unicode classes will have a class method called 'cformat' that does all the actual work of formatting; The format() method is

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Terry Reedy
Martin v. Löwis [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Terry Reedy wrote: Now, suppose you wanted to have 'key' be a keyword-only argument. Why? Why not let the user type the additional argument(s) without the parameter name? Are you asking why that feature

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Terry Reedy
Nick Coghlan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Terry Reedy wrote: Talin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Now, suppose you wanted to have 'key' be a keyword-only argument. Why? Why not let the user type the additional argument(s)

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Terry Reedy
Martin v. Löwis [EMAIL PROTECTED] wrote in message Are you asking why that feature (keyword-only arguments) is desirable? Joe Smith asked essentially the same question in a different way: However, I'm not sure what the use case is for keyword only arguments on functions that do *not* accept a

Re: [Python-Dev] More on contextlib - adding back a contextmanager decorator

2006-04-30 Thread Nick Coghlan
Guido van Rossum wrote: On 4/30/06, Nick Coghlan [EMAIL PROTECTED] wrote: A few things from the pre-alpha2 context management terminology review have had a chance to run around in the back of my head for a while now, and I'd like to return to a topic Paul Moore brought up during that

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Edward Loper
Terry Reedy wrote: There are two subproposals: first, keyword-only args after a variable number of positional args, which requires allowing keyword parameter specifications after the *args parameter, and second, keyword-only args after a fixed number number of positional args, implemented

Re: [Python-Dev] More on contextlib - adding back a contextmanager decorator

2006-04-30 Thread Guido van Rossum
[I'm cutting straight to the chase here] On 4/30/06, Nick Coghlan [EMAIL PROTECTED] wrote: The downside of this over the __context__ method is that it is neither nesting nor thread-safe. This argument is bogus. We currently have two types of objects involved in with-statements: those whose

Re: [Python-Dev] More on contextlib - adding back a contextmanager decorator

2006-04-30 Thread Phillip J. Eby
At 08:08 PM 4/30/2006 -0700, Guido van Rossum wrote: If you object against the extra typing, we'll first laugh at you (proposals that *only* shave a few characters of a common idiom aren't all that popular in these parts), and then suggest that you can spell foo.some_method() as foo(). Okay,

Re: [Python-Dev] methods on the bytes object

2006-04-30 Thread Josiah Carlson
Martin v. Löwis [EMAIL PROTECTED] wrote: Josiah Carlson wrote: I think what you are missing is that algorithms that currently operate on byte strings should be reformulated to operate on character strings, not reformulated to operate on bytes objects. By character strings can I

Re: [Python-Dev] methods on the bytes object

2006-04-30 Thread Martin v. Löwis
Josiah Carlson wrote: I mean unicode strings, period. I can't imagine what unicode strings which do not contain data could be. Binary data as opposed to text. Input to a array.fromstring(), struct.unpack(), etc. You can't/shouldn't put such data into character strings: you need an encoding

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Martin v. Löwis
Terry Reedy wrote: Are you asking why that feature (keyword-only arguments) is desirable? That's the whole point of the PEP. Or are you asking why the user shouldn't be allowed to pass keyword-only arguments by omitting the keyword? Because they wouldn't be keyword-only arguments then,

Re: [Python-Dev] PEP 3102: Keyword-only arguments

2006-04-30 Thread Martin v. Löwis
Terry Reedy wrote: Now, suppose you wanted to have 'key' be a keyword-only argument. Why? Why not let the user type the additional argument(s) without the parameter name? Like Martin, you clipped most of the essential context of my question: Talin's second proposal. I clipped it