[Python-Dev] Mini-Pep: An Empty String ABC

2008-06-06 Thread Jim Jewett
> So, apart from compatibility purposes, what is the > point currently of *not* directly subclassing str? To provide your own storage format, such as a views into existing data. Whether or not this is actually practical is a different question; plenty C code tends to assume it can use the interna

Re: [Python-Dev] Mini-Pep: An Empty String ABC

2008-06-04 Thread Guido van Rossum
Given the lack of responses to my questions, let's reject this. -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://ma

Re: [Python-Dev] Mini-Pep: An Empty String ABC

2008-06-03 Thread Raymond Hettinger
From: "Antoine Pitrou" <[EMAIL PROTECTED]> It seems to me that Sequence.index()/count() and String.index()/count() shouldn't have the same semantics. In the former case they search for items in the Sequence, in the latter case they search for substrings of the String. And the same applies to _

Re: [Python-Dev] Mini-Pep: An Empty String ABC

2008-06-03 Thread Antoine Pitrou
Raymond Hettinger rcn.com> writes: > > By subclassing Sequence, we get index() and count() mixins for free. > It seems to me that Sequence.index()/count() and String.index()/count() shouldn't have the same semantics. In the former case they search for items in the Sequence, in the latter case

Re: [Python-Dev] Mini-Pep: An Empty String ABC

2008-06-02 Thread Guido van Rossum
Please try to find the largest set of methods that you're comfortable with. __add__ comes to mind. Note that if you add __hash__, this rules out bytearray -- is that your intention? __hash__ is intentionally not part of the "read-only" ABCs because read-only doesn't mean immutable. Also, (again)

Re: [Python-Dev] Mini-Pep: An Empty String ABC

2008-06-02 Thread Raymond Hettinger
From: "Guido van Rossum" <[EMAIL PROTECTED]> All this makes me lean towards a rejection of this proposal -- it seems worse than no proposal at all. It could perhaps be rescued by adding some small set of defined operations. By subclassing Sequence, we get index() and count() mixins for free. W

Re: [Python-Dev] Mini-Pep: An Empty String ABC

2008-06-02 Thread Nick Coghlan
Guido van Rossum wrote: This PEP is incomplete without specifying exactly which built-in and stdlib types should be registered as String instances. I'm also confused -- the motivation seems mostly "so that you can skip iterating over it when flattening a nested sequence" but earlier you rejected

Re: [Python-Dev] Mini-Pep: An Empty String ABC

2008-06-01 Thread Guido van Rossum
This PEP is incomplete without specifying exactly which built-in and stdlib types should be registered as String instances. I'm also confused -- the motivation seems mostly "so that you can skip iterating over it when flattening a nested sequence" but earlier you rejected my "Atomic" proposal, say

Re: [Python-Dev] Mini-Pep: An Empty String ABC

2008-06-01 Thread Antoine Pitrou
Raymond Hettinger rcn.com> writes: > Also, starting with Py3.0, strings are > essentially abstract sequences of code points, meaning that an encode() method > is essential to being able to usefully transform them back into concrete data. Well, that depends: - is a String the specification of a ge

[Python-Dev] Mini-Pep: An Empty String ABC

2008-05-31 Thread Raymond Hettinger
Mini-Pep: An Empty String ABC Target: Py2.6 and Py3.0 Author: Raymond Hettinger Proposal Add a new collections ABC specified as: class String(Sequence): pass Motivation -- Having an ABC for strings allows string look-alike classes to declare themselves as sequence