Re: [Python-3000] Python3 - it's awesome (fwd)

2008-11-19 Thread Walter Dörwald
Michael Bayer wrote: [...] It will be critical that we get DBAPI implementations going soon, other than pysqlite I haven't perceived any activity in that area. It will be interesting to see if we remain with the maintsays of MySQLdb, psycopg2, cx_oracle, or if new 3.0-era contenders come on

Re: [Python-3000] [Python-Dev] Betas today - I hope

2008-06-13 Thread Walter Dörwald
Walter Dörwald wrote: [...] Sure, we could do that, but please use a different name, e.g. .encodeall() and .decodeall() - .encode() and .decode() are already stateles (and so would the new methods be), so "stateless" isn't all that meaningful in this context. I like the

Re: [Python-3000] [Python-Dev] Betas today - I hope

2008-06-13 Thread Walter Dörwald
M.-A. Lemburg wrote: On 2008-06-13 11:32, Walter Dörwald wrote: M.-A. Lemburg wrote: On 2008-06-12 16:59, Walter Dörwald wrote: M.-A. Lemburg wrote: .transform() and .untransform() use the codecs to apply same-type conversions. They do apply type checks to make sure that the codec does

Re: [Python-3000] [Python-Dev] Betas today - I hope

2008-06-13 Thread Walter Dörwald
M.-A. Lemburg wrote: On 2008-06-12 16:59, Walter Dörwald wrote: M.-A. Lemburg wrote: .transform() and .untransform() use the codecs to apply same-type conversions. They do apply type checks to make sure that the codec does indeed return the same type. E.g. text.transform('xml-escape

Re: [Python-3000] [Python-Dev] Betas today - I hope

2008-06-12 Thread Walter Dörwald
M.-A. Lemburg wrote: On 2008-06-11 17:15, Walter Dörwald wrote: M.-A. Lemburg wrote: On 2008-06-11 13:35, Barry Warsaw wrote: So I had planned to do a bunch of work last night looking at the release blocker issues, but nature intervened. A bunch of severe thunderstorms knock out my 

Re: [Python-3000] Betas today - I hope

2008-06-11 Thread Walter Dörwald
M.-A. Lemburg wrote: On 2008-06-11 13:35, Barry Warsaw wrote: So I had planned to do a bunch of work last night looking at the release blocker issues, but nature intervened. A bunch of severe thunderstorms knock out my 'net access until this morning. I'll try to find some time during the day

Re: [Python-3000] u'text' as an alias for 'text'?

2008-03-20 Thread Walter Dörwald
Christian Heimes wrote: > Barry Warsaw schrieb: >> I proposed what I think is a better solution. Add >> >> from __future__ import unicode_strings >> >> to Py2.6. That would let you write Py3k compatible strings (and of >> course byte literals) in 2.6. It would essential treat 'foo' as >> u'f

Re: [Python-3000] Need help with menial tasks

2007-11-22 Thread Walter Dörwald
Amaury Forgeot d'Arc wrote: > Guido van Rossum: >> I just changed PEP 3137 to rename the mutable bytes type 'bytearray' >> instead of 'buffer', and implemented this change in the py3k branch. >> >> A lot of code in the Py3k branch still returns PyBytes instances >> (i.e., bytearray) where it should

Re: [Python-3000] Python 3.0a2 release

2007-11-20 Thread Walter Dörwald
Guido van Rossum wrote: > On Nov 19, 2007 3:06 PM, Amaury Forgeot d'Arc <[EMAIL PROTECTED]> wrote: >> Guido van Rossum wrote: >>> Is there anything that you (or anyone else!) would really like to see >>> added to or fixed in 3.0a2? Now's the time! >> I am currently having a look at http://bugs.pyth

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Walter Dörwald
Guido van Rossum wrote: > Please comment. > [...] > Conversions between bytes or buffer objects and str objects must > always be explicit, using an encoding. There are two equivalent APIs: > ``str(b, [, ])`` is equivalent to > ``b.encode([, ])``, and > ``bytes(s, [, ])`` is equivalent to > ``s.d

Re: [Python-3000] current status

2007-08-30 Thread Walter Dörwald
Walter Dörwald wrote: > [...] > However test_tarfile.py still segfaults for me in the py3k branch. The > top of the stacktrace is: > > #0 0xb7eec07f in memcpy () from /lib/tls/libc.so.6 > #1 0xb7a905bc in s_pack_internal (soself=0xb77dc97c, args=0xb77cddfc, > of

Re: [Python-3000] current status

2007-08-30 Thread Walter Dörwald
Guido van Rossum wrote: > [...[ > >> * On ia64, test_tarfile.PAXUnicodeTest.test_utf7_filename generates >> this exception: >> Objects/exceptions.c:1392: PyUnicodeDecodeError_Create: Assertion >> `start < 2147483647' failed. > > That's probably an uninitialized variable 'startinpos' in one of th

Re: [Python-3000] UTF-32 codecs

2007-08-17 Thread Walter Dörwald
Guido van Rossum wrote: > On 8/16/07, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> Martin v. Löwis wrote: >> >>>> A simple merge won't work, because in 3.0 the codec uses bytes and in >>>> 2.6 it uses str. Also the call to the decoding error

Re: [Python-3000] Two new test failures (one OSX PPC only)

2007-08-17 Thread Walter Dörwald
Guido van Rossum wrote: > I see two new tests failing tonight: > > - test_xmlrpc fails on all platforms I have. This is due to several > new tests that were merged in from the trunk; presumably those tests > need changes due to str vs. bytes. > > - test_codecs fails on OSX PPC only. This is in t

Re: [Python-3000] UTF-32 codecs

2007-08-16 Thread Walter Dörwald
Martin v. Löwis wrote: >> A simple merge won't work, because in 3.0 the codec uses bytes and in >> 2.6 it uses str. Also the call to the decoding error handler has >> changed, because in 3.0 the error handler could modify the mutable input >> buffer. > > So what's the strategy then? Block the tru

Re: [Python-3000] UTF-32 codecs

2007-08-16 Thread Walter Dörwald
Martin v. Löwis wrote: >> OK, then I'll check it into the py3k branch, and backport it to the trunk. > > This raises another procedural question: are we still merging from the > trunk to the 3k branch, or are they now officially split? > > If we still merge, and assuming that the implementations

Re: [Python-3000] UTF-32 codecs

2007-08-16 Thread Walter Dörwald
Guido van Rossum wrote: > On 8/16/07, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: >> Walter Dörwald schrieb: >>> I have a patch against the py3k branch (http://bugs.python.org/1775604) >>> that adds UTF-32 codecs. On a narrow build it combines surroga

[Python-3000] UTF-32 codecs

2007-08-16 Thread Walter Dörwald
I have a patch against the py3k branch (http://bugs.python.org/1775604) that adds UTF-32 codecs. On a narrow build it combines surrogate pairs in the unicode object into one codepoint on encoding and creates surrogate pairs for codepoints outside the BMP on decoding. Should I apply this to the py3

Re: [Python-3000] More PEP 3101 changes incoming

2007-08-14 Thread Walter Dörwald
Ron Adam wrote: > > Greg Ewing wrote: >> Ron Adam wrote: >> >>> The digits value are number of digits before the decimal. This doesn't >>> include the other symbols used in the field so it isn't the same as a field >>> width. >> How does this work with formats where the number of >> digits befo

Re: [Python-3000] Move to a "py3k" branch *DONE*

2007-08-10 Thread Walter Dörwald
Neal Norwitz wrote: > [...] > Code to trigger a leak: b'\xff'.decode("utf8", "ignore") This should be fixed in r56894. > [...] Servus, Walter ___ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000

Re: [Python-3000] C API cleanup str

2007-08-06 Thread Walter Dörwald
Martin v. Löwis wrote: >>> I now tried, and it turned out that bytes.__reduce__ would break >>> (again); I fixed it and changed it in r56755. >>> >>> It turned out that PyUnicode_FromString was even documented to >>> accept latin-1. >> Yes, that seemed to me to be the most obvious interpretion. >

Re: [Python-3000] C API cleanup str

2007-08-06 Thread Walter Dörwald
Martin v. Löwis wrote: >> You mean if it were fixed it could fail, right? Code calling it should >> be checking for errors anyway because it allocates memory. >> >> Have you tried making this particular change and seeing what fails? > > I now tried, and it turned out that bytes.__reduce__ would b

Re: [Python-3000] Need help fixing failing Py3k Unittests in py3k-struni

2007-07-12 Thread Walter Dörwald
Guido van Rossum wrote: > On 7/11/07, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> I guess for the final version of Py3000 type_set_name() in typeobject.c >> will not downgrade unicode strings to str8, but instead upgrade str8 >> objects to unicode. > > Right,

Re: [Python-3000] Need help fixing failing Py3k Unittests in py3k-struni

2007-07-11 Thread Walter Dörwald
t; Yeah, I'm looking in to this right now. What a mess! But I'm close to >> a fix. >> >> There's more that causes test_descr to fail however. Bleh, what a >> terrible unit test -- it doesn't use the unittest module, and a single >> failure aborts

Re: [Python-3000] Need help fixing failing Py3k Unittests in py3k-struni

2007-07-11 Thread Walter Dörwald
Christian Heimes wrote: > I found a bug in the str type that may affect a lot of tests. > > In the py3k-struni branch the str() constructor doesn't use __str__ when > the argument is an instance of a subclass of str. A user defined string > can't change __str__(). The __repr__ method isn't affect

Re: [Python-3000] setup.py fails in the py3k-struni branch

2007-06-20 Thread Walter Dörwald
Ron Adam wrote: > [...] > M Lib/tokenize.py > M Lib/test/tokenize_tests.txt > M Lib/test/output/test_tokenize > - Removed unicode literals from test results and tokenize.py. And make > it pass again. > > > M Lib/test/output/test_pep277 > - Removed unicode literals from test

Re: [Python-3000] [Python-Dev] Python 3000 Status Update (Long!)

2007-06-19 Thread Walter Dörwald
Georg Brandl wrote: > Walter Dörwald schrieb: >> Georg Brandl wrote: >>> Nick Coghlan schrieb: >>>> Georg Brandl wrote: >>>>> Guido van Rossum schrieb: >>>>>> I've written up a comprehensive status report on Python 3000. Please &

Re: [Python-3000] [Python-Dev] Python 3000 Status Update (Long!)

2007-06-19 Thread Walter Dörwald
Georg Brandl wrote: > Nick Coghlan schrieb: >> Georg Brandl wrote: >>> Guido van Rossum schrieb: I've written up a comprehensive status report on Python 3000. Please read: http://www.artima.com/weblogs/viewpost.jsp?thread=208549 >>> Thank you! Now I have something to show to interest

[Python-3000] binascii.b2a_qp() in the p3yk branch

2007-05-09 Thread Walter Dörwald
binascii.b2a_qp() in the p3yk branch is broken. What I get is: $ gdb ./python GNU gdb 6.3-debian Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions.

Re: [Python-3000] [Python-3000-checkins] r54742 - in python/branches/p3yk/Lib: io.py test/test_io.py

2007-04-13 Thread Walter Dörwald
Guido van Rossum wrote: >> >> > I wonder if it would be possible to return the state as a pair >> >> > (unread, flags) where unread is a (byte) string of unprocessed bytes >> >> > and flags is some other state, with the constraint that in the >> initial >> >> > state the flags must be zero. Then I

Re: [Python-3000] [Python-3000-checkins] r54742 - in python/branches/p3yk/Lib: io.py test/test_io.py

2007-04-12 Thread Walter Dörwald
Guido van Rossum wrote: > On 4/12/07, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> Guido van Rossum wrote: >> > On 4/11/07, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> >> Would it make sense to make the state of the decoder public, e.g. by >> &

Re: [Python-3000] [Python-3000-checkins] r54742 - in python/branches/p3yk/Lib: io.py test/test_io.py

2007-04-12 Thread Walter Dörwald
Guido van Rossum wrote: > On 4/11/07, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> Would it make sense to make the state of the decoder public, e.g. by >> adding setstate() and getstate() methods? This would give a cleaner API. > > I've been thinking of the same

Re: [Python-3000] [Python-3000-checkins] r54742 - in python/branches/p3yk/Lib: io.py test/test_io.py

2007-04-11 Thread Walter Dörwald
guido.van.rossum wrote: > Author: guido.van.rossum > Date: Wed Apr 11 03:09:03 2007 > New Revision: 54742 > > Modified: >python/branches/p3yk/Lib/io.py >python/branches/p3yk/Lib/test/test_io.py > Log: > Checkpoint so I can continue to work on this at a different box. > There is somewhat w

Re: [Python-3000] Draft PEP for New IO system

2007-02-27 Thread Walter Dörwald
Guido van Rossum wrote: > On 2/27/07, Walter Dörwald <[EMAIL PROTECTED]> wrote: > [...] >> The basic principle is that these codecs can encode strings and decode >> bytes in multiple chunks. If you want to encode a unicode string u in >> UTF-16 you can do it in one g

Re: [Python-3000] Draft PEP for New IO system

2007-02-27 Thread Walter Dörwald
Guido van Rossum wrote: > On 2/27/07, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> Guido van Rossum wrote: >> >> > The encoding/decoding behavior should be no different from that of the >> > encode() and decode() methods on unicode strings and byte ar

Re: [Python-3000] Draft PEP for New IO system

2007-02-27 Thread Walter Dörwald
Guido van Rossum wrote: > The encoding/decoding behavior should be no different from that of the > encode() and decode() methods on unicode strings and byte arrays. Except that it must work in incremental mode. The new (in 2.5) incremental codecs should be usable for that. > Certainly no normal

Re: [Python-3000] __nonzero__ vs. __bool__

2006-11-22 Thread Walter Dörwald
Jack Diederich wrote: > On Wed, Nov 22, 2006 at 09:36:09AM +0100, Georg Brandl wrote: >> Terry Reedy schrieb: >>> "Brett Cannon" <[EMAIL PROTECTED]> wrote in message >>> news:[EMAIL PROTECTED] >>> >>> Why can't the fallback usage just pass the return value from __len__ to >>> bool() (forget the

Re: [Python-3000] Abilities / Interfaces

2006-11-22 Thread Walter Dörwald
Guido van Rossum wrote: > On 11/21/06, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > [...] >> That's because some generic functions use if-isinstance checks (bad), while >> others use custom __special__ methods (not bad, but not great), registries >> (good), adaptation (okay), or generic function lib

Re: [Python-3000] BOM handling

2006-09-14 Thread Walter Dörwald
Josiah Carlson wrote: > Antoine Pitrou <[EMAIL PROTECTED]> wrote: >> >> Le mercredi 13 septembre 2006 à 09:41 -0700, Josiah Carlson a écrit : >>> And is generally ignored, as per unicode spec; it's a "zero width >>> non-breaking space" - an invisible character with no effect on wrapping >>> or othe

Re: [Python-3000] Pre-PEP: Easy Text File Decoding

2006-09-13 Thread Walter Dörwald
Jason Orendorff wrote: > On 9/13/06, John S. Yates, Jr. <[EMAIL PROTECTED]> wrote: >> It is a mistake on Microsoft's part to fail to strip the BOM >> during conversion to UTF-8. > > John, you're mistaken about the reason this BOM is here. > > In Notepad at least, the BOM is intentionally generate

Re: [Python-3000] Pre-PEP: Easy Text File Decoding

2006-09-11 Thread Walter Dörwald
Paul Prescod wrote: > I went based on the current setdefaultencoding. But it seems that we will > accumulate 3 or 4 related functions so I'm pursuaded that there should be a > module. > > encodingdetection.setdefaultfileencoding > encodingdetection.registerencodingdetector > encodingdetection.gues

Re: [Python-3000] Comment on iostack library

2006-08-31 Thread Walter Dörwald
tomer filiba wrote: > [...] > besides, encoding suffers from many issues. suppose you have a > damaged UTF8 file, which you read char-by-char. when we reach the > damaged part, you'll never be able to "skip" it, as we'll just keep > read()ing bytes, hoping to make a character out of it , until we

Re: [Python-3000] Droping find/rfind?

2006-08-24 Thread Walter Dörwald
Guido van Rossum wrote: > I don't find the current attempts to come up with a better substring > search API useful. > > [...] > > I appreciate the criticism on the patch -- clearly it's not ready to > go in, and more work needs to be put in to actually *improve* the > code, using [r]partition()

Re: [Python-3000] callable()

2006-07-21 Thread Walter Dörwald
Guido van Rossum wrote: > On 7/20/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> str and unicode don't have __iter__, list, tuple and dict do: > [...] >> Should that be fixed too? > > Yes, please. (In Python 2.6 if you can.) Here's the patch: bu

Re: [Python-3000] callable()

2006-07-20 Thread Walter Dörwald
Guido van Rossum wrote: > On 7/18/06, Greg Ewing <[EMAIL PROTECTED]> wrote: >> Andrew Koenig wrote: >> >>> I am uncomfortable about exposing the implementation this way, if only >>> because it would require fixing the equivalence between callable() and >>> hasattr(obj, '__call__') for all time. >>

Re: [Python-3000] Automatically invoking str() in str.join()

2006-05-01 Thread Walter Dörwald
Nick Coghlan wrote: > Thomas Wouters wrote: >> It doesn't matter. Either case is confusing, one way or another, as Tim >> has already argued. Changing it would be a big mistake. If you want me >> to come with more comprehensive arguments (other than what Tim already >> covered), please come with

Re: [Python-3000] Chaning the import machinery; was: Re: [Python-Dev] setuptools in 2.5.

2006-04-21 Thread Walter Dörwald
Guido van Rossum wrote: > On 4/20/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> Guido van Rossum wrote: >> >> > Sorry, there's so much here that seems poorly thought out that I don't >> > know where to start. >> >> Consider it a

Re: [Python-3000] Chaning the import machinery; was: Re: [Python-Dev] setuptools in 2.5.

2006-04-20 Thread Walter Dörwald
Guido van Rossum wrote: > Sorry, there's so much here that seems poorly thought out that I don't > know where to start. Consider it a collection of wild ideas. > Getting rid of the existing import syntax in favor of the incredibly > verbose and ugly > > foo = import("foo") > > just isn't acc

[Python-3000] Chaning the import machinery; was: Re: [Python-Dev] setuptools in 2.5.

2006-04-20 Thread Walter Dörwald
Guido van Rossum wrote: > On 4/20/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> I'd like to be able to simply import a file if I have the filename. And >> I'd like to be able to load sourcecode from an Oracle database and have >> useful "filena

Re: [Python-3000] Use Py_CLEAR only

2006-04-19 Thread Walter Dörwald
Greg Ewing wrote: > Walter Dörwald wrote: > >> The "checking for NULL" scenario looks somewhat like this: >> >> And the "clearing the reference" scenario should look ike this: > > But only if the reference is a local to the function, True P

Re: [Python-3000] Use Py_CLEAR only

2006-04-19 Thread Walter Dörwald
Greg Ewing wrote: > Walter Dörwald wrote: >> Greg Ewing wrote: >>> It would be less efficient in the cases where you don't >>> need to check for NULL and/or clear the reference >>> afterwards. >> >> Both should be optimized away by the comp

Re: [Python-3000] Use Py_CLEAR only

2006-04-18 Thread Walter Dörwald
Greg Ewing wrote: > Edward C. Jones wrote: > >> Can Py_CLEAR completely replace Py_DECREF and Py_XDECREF? > > It would be less efficient in the cases where you don't > need to check for NULL and/or clear the reference > afterwards. Both should be optimized away by the compiler. But what we gai

Re: [Python-3000] Cleaning up argument list parsing (was Re: More wishful thinking)

2006-04-17 Thread Walter Dörwald
Guido van Rossum wrote: > On 4/17/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: >> The rest of it was just suggesting that permitting keyword >> parameters/arguments after *args should be the *only* change we make in this >> area. I don't see any point in permitting positional arguments to come after

Re: [Python-3000] Adaption & generic functions [was Generic functions]

2006-04-08 Thread Walter Dörwald
Guido van Rossum sagte: > On 4/7/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> An Interface is an abstract class that you subclass to make it a concrete >> implementation. > > That's not the view of most people who use the word interface these days. Not > i

Re: [Python-3000] Adaption & generic functions [was Generic functions]

2006-04-07 Thread Walter Dörwald
Guido van Rossum wrote: > On 4/7/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >>> Using @overloaded functions I would create an explicit class variable >>> which is the @overloaded adapter rather than trying to make the >>> interface also *be* the adapter

Re: [Python-3000] Adaption & generic functions [was Generic functions]

2006-04-07 Thread Walter Dörwald
Jim Jewett wrote: > On 4/5/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: > >> class Sequence(Interface): >> def getitem(self, index): pass >> def len(self): pass > >> class PythonSeqAsSequence(Sequence): >> def __init__(self, obj): >&g

Re: [Python-3000] Adaption & generic functions [was Generic functions]

2006-04-07 Thread Walter Dörwald
Guido van Rossum wrote: > On 4/5/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> But might closes off one route we could take if we're adapting to >> something that must provide more than one function/method (i.e. an >> interface) and we'd like to have th

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Walter Dörwald
Guido van Rossum wrote: > On 4/5/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> The problem with this is that it looks in the base protocol only if the >> the class can't be found in the registry of the subprotocol. This mean >> that an adapter from the subprot

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Walter Dörwald
Tim Hochberg wrote: > Walter Dörwald wrote: > >> Guido van Rossum wrote: >> >>> On 4/5/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >>> >>>> Guido van Rossum wrote: >>>> >>>>> On 4/5/06, Tim Hochberg <[EMAIL

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Walter Dörwald
Guido van Rossum wrote: > On 4/5/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> Guido van Rossum wrote: >> >>> On 4/5/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: >>>> I'm hoping that Walter can give some more realistic examples since I >&

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Walter Dörwald
Tim Hochberg wrote: > Guido van Rossum wrote: > >> On 4/5/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: >> >> >>> Walter Dörwald wrote: >>> >>> >>>> What's still missing IMHO is a way for an a

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Walter Dörwald
Guido van Rossum wrote: > On 4/5/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: >> I'm hoping that Walter can give some more realistic examples since I >> don't have real-world experience here. The basic idea is simply to let >> an adapter give up and let the protocol try the next adapter. This could

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Walter Dörwald
Guido van Rossum wrote: > Fascinating ideas in this thread! > > I spent some time blogging about this on artima: > http://www.artima.com/weblogs/viewpost.jsp?thread=155123 > > I have to write my slides for a talk about Py3K later today, but I'll > be back. In the mean time I've rejected PEPs 245

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Walter Dörwald
Nick Coghlan wrote: > [...] > def default_adapter(self, *args): > """Call result when no adapter was found""" > raise TypeError("Can't adapt %s to %s" % > (args[0].__class__.__name__, self.name)) +1 This makes it easy to add fallbacks: class XReprP

Re: [Python-3000] Adaption & generic functions [was Generic functions]

2006-04-05 Thread Walter Dörwald
Nick Coghlan wrote: > [...] > So your example would become: > > class MetaInterface(type): > def __new__(mcl, name, bases, dict): > # Give each class it's own registry > cls = type.__new__(mcl, name, bases, dict) > cls.registry = {} > return cls > >

Re: [Python-3000] Adaption & generic functions [was Generic functions]

2006-04-05 Thread Walter Dörwald
t Sequence.adapt([1,2,3]).len() But if adapting is done via __call__() we have a problem: Sequence already provides a __call__, the constructor. Of course if this worked print Sequence([1,2,3]).len() would look much better than print Sequence.adapt([1,2,3]).len() but I'm not sure if it's

Re: [Python-3000] Generic functions

2006-04-04 Thread Walter Dörwald
Ian Bicking wrote: > Walter Dörwald wrote: >> What happens, if I do the following >> >> @PrettyPrinter.pformat.when(object=list) >> def foo(...): >>... >> >> @PrettyPrinter.pformat.when(object=object) >> def foo(...): >>... &g

Re: [Python-3000] Generic functions

2006-04-04 Thread Walter Dörwald
s, and other things I probably haven't > thought of. But anyway, this allows: > > class PrettyPrinter: > def pformat(self, object): ... > > # Without keyword arguments I have to give a wildcard for the self > # argument..

Re: [Python-3000] Adaptation [was:Re: Iterators for dict keys, values, and items == annoying :)]

2006-04-03 Thread Walter Dörwald
Alex Martelli wrote: > On Apr 2, 2006, at 4:39 PM, Walter Dörwald wrote: >... >> Why not make the registry identical to the protocol? The protocol is >> just a convention anyway: > > Yes, a 1<->1 relationship between registries and protocols makes the > &#

Re: [Python-3000] String formating operations in python 3k

2006-04-02 Thread Walter Dörwald
ings. > 3 I am not arguing _against_ syntactic support, I am arguing _for_ a method; >we can keep the syntactic support. and it avoids one problem you might run into with %: If you have only one argument, writing ``s % (x,)`` as ``s % x`` will break when the argument x happens to be a tup

Re: [Python-3000] Adaptation [was:Re: Iterators for dict keys, values, and items == annoying :)]

2006-04-02 Thread Walter Dörwald
all sort of "cruft" to be piled on top. I think you might be misinterpreting reactions. If the initial reaction was "I don't understand it. Nobody needs this." (at least that was my reaction), you're "strawman proposal" has put us past

Re: [Python-3000] Adaptation [was:Re: Iterators for dict keys, values, and items == annoying :)]

2006-04-01 Thread Walter Dörwald
I would use this adaption module). At the minimum this module should support inheritance of the adapted type, so a simple dict won't work. Defining an adaptor for the copy protocol might look like this: @adaptor(Foo, "org.python.copy") class CopyFoo: def __init