Re: [Python-Dev] Polymorphic best practices

2010-09-18 Thread John Nagle
On 9/18/2010 2:29 AM, python-dev-requ...@python.org wrote: Polymorphic best practices [was: (Not) delaying the 3.2 release] If you're hung up on this, try writing the user-level documentation first. Your target audience is a working-level Web programmer, not someone who knows six

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-17 Thread Baptiste Carvello
R. David Murray a écrit : I'm trying one approach in email6: Bytes and String subclasses, where the subclasses have an attribute named 'literals' derived from a utility module that does this: literals = dict( empty = '', colon = ':', newline = '\n', space = '

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-17 Thread Antoine Pitrou
Le jeudi 16 septembre 2010 à 22:51 -0400, R. David Murray a écrit : On disk, using utf-8, one might store the text representation of the message, rather than the wire-format (ASCII encoded) version. We might want to write such messages from scratch. But then the user knows the

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-17 Thread Barry Warsaw
On Sep 17, 2010, at 12:10 PM, Antoine Pitrou wrote: Also, I don't understand why an application would want to assemble an e-mail by itself if it doesn't know how to do so, and produces wrong data. Why not simply let the application do: m = Message() m.add_header(From, Accented Bàrry

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-17 Thread Barry Warsaw
On Sep 16, 2010, at 11:45 PM, Terry Reedy wrote: Based on the discussion so far, I think you should go ahead and implement the API agreed on by the mail sig both because is *has* been agreed on (and thinking about the wsgi discussion, that seems to be a major achievement) and because it seems

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-17 Thread Michael Foord
On 16/09/2010 23:05, Antoine Pitrou wrote: On Thu, 16 Sep 2010 16:51:58 -0400 R. David Murrayrdmur...@bitdance.com wrote: What do we store in the model? We could say that the model is always text. But then we lose information about the original bytes message, and we can't reproduce it. For

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-17 Thread Ian Bicking
On Fri, Sep 17, 2010 at 3:25 PM, Michael Foord fuzzy...@voidspace.org.ukwrote: On 16/09/2010 23:05, Antoine Pitrou wrote: On Thu, 16 Sep 2010 16:51:58 -0400 R. David Murrayrdmur...@bitdance.com wrote: What do we store in the model? We could say that the model is always text. But then

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread R. David Murray
On Thu, 16 Sep 2010 09:52:48 -0400, Barry Warsaw ba...@python.org wrote: On Sep 16, 2010, at 11:28 PM, Nick Coghlan wrote: There are some APIs that should be able to handle bytes *or* strings, but the current use of string literals in their implementation means that bytes don't work. This

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread Antoine Pitrou
On Thu, 16 Sep 2010 11:30:12 -0400 R. David Murray rdmur...@bitdance.com wrote: And then BaseHeader uses self.lit.colon, etc, when manipulating strings. It also has to use slice notation rather than indexing when looking at individual characters, which is a PITA but not terrible. I'm not

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread R. David Murray
On Thu, 16 Sep 2010 17:40:53 +0200, Antoine Pitrou solip...@pitrou.net wrote: On Thu, 16 Sep 2010 11:30:12 -0400 R. David Murray rdmur...@bitdance.com wrote: And then BaseHeader uses self.lit.colon, etc, when manipulating strings. It also has to use slice notation rather than indexing

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread Antoine Pitrou
On Thu, 16 Sep 2010 16:51:58 -0400 R. David Murray rdmur...@bitdance.com wrote: What do we store in the model? We could say that the model is always text. But then we lose information about the original bytes message, and we can't reproduce it. For various reasons (mailman being a big one),

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread Glyph Lefkowitz
On Sep 16, 2010, at 4:51 PM, R. David Murray wrote: Given a message, there are many times you want to serialize it as text (for example, for presentation in a UI). You could provide alternate serialization methods to get text out on demandbut then what if someone wants to push that text

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread Barry Warsaw
On Sep 16, 2010, at 06:11 PM, Glyph Lefkowitz wrote: That may be a handy way to deal with some grotty internal implementation details, but having a 'decode()' method is broken. The thing I care about, as a consumer of this API, is that there is a clearly defined Message interface, which gives me

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread Glyph Lefkowitz
On Sep 16, 2010, at 7:34 PM, Barry Warsaw wrote: On Sep 16, 2010, at 06:11 PM, Glyph Lefkowitz wrote: That may be a handy way to deal with some grotty internal implementation details, but having a 'decode()' method is broken. The thing I care about, as a consumer of this API, is that

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread R. David Murray
On Thu, 16 Sep 2010 18:11:30 -0400, Glyph Lefkowitz gl...@twistedmatrix.com wrote: On Sep 16, 2010, at 4:51 PM, R. David Murray wrote: Given a message, there are many times you want to serialize it as text (for example, for presentation in a UI). You could provide alternate

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread Barry Warsaw
On Sep 16, 2010, at 09:34 PM, R. David Murray wrote: Say we start with this bytes input: To: Glyph Lefkowitz gl...@twistedmatrix.com From: R. David Murray rdmur...@bitdance.com Subject: =?utf-8?q?p=F6stal?= A simple message. Part of the responsibility of the email module is to

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread Steven D'Aprano
On Fri, 17 Sep 2010 11:34:26 am R. David Murray wrote: Perhaps another difference is that in my mind *as an application developer*, the real email message consists of unicode headers and message bodies, with attachments that are sometimes binary, and that the wire-format is this formalized

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread R. David Murray
On Fri, 17 Sep 2010 00:05:12 +0200, Antoine Pitrou solip...@pitrou.net wrote: On Thu, 16 Sep 2010 16:51:58 -0400 R. David Murray rdmur...@bitdance.com wrote: What do we store in the model? We could say that the model is always text. But then we lose information about the original bytes

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread R. David Murray
On Thu, 16 Sep 2010 21:53:17 -0400, Barry Warsaw ba...@python.org wrote: And of course, what happens if the original subject is in one charset and the prefix is in an incompatible one? Then you end up with a wire format of two RFC 2047 encoded words separated by whitespace. You have to keep

Re: [Python-Dev] Polymorphic best practices [was: (Not) delaying the 3.2 release]

2010-09-16 Thread R. David Murray
On Thu, 16 Sep 2010 23:45:12 -0400, Terry Reedy tjre...@udel.edu wrote: Based on the discussion so far, I think you should go ahead and implement the API agreed on by the mail sig both because is *has* been agreed on (and thinking about the wsgi discussion, that seems to be a major