[Python-3000] Need help completing ABC pep

Guido van Rossum guido at python.org
Fri Apr 20 23:33:01 CEST 2007


On 4/20/07, Bill Janssen <janssen at parc.com> wrote:
> Where do strings and bytes fit in?  They seem to be sequences.  Are
> they sub-typable?  If so, shouldn't their base interface be defined?

Yes, yes and yes. I haven't gotten to them yet. :-)

> I'd either add numeric types to this, or split it in two pieces: one
> about ABCs in general (perhaps defining Comparable and Object), and
> another for collection types.  Then a third for numeric types.

Yeah, I'm thinking of at least separating the numeric types. I'd like
to keep the collections in the same PEP as the general topics just so
that it shows "what can ABCs do for you".

> I don't like the name of the "pop()" method on Sets.  It's too much
> associated with stacks.  People reading code that uses "pop" on a value
> will naturally assume that the value is a stack.  I'd prefer
> "remove_and_return_random_item()".

Yeah, but it has a long history in Python. Python 2's sets have a
pop() method, and dicts have an equivalent popitem() method (as well
as a pop() that requires you to specify a key).

> > You will still be able to assign any "file-like" object to
> > sys.stdout, as long as it has a write method.
>
> Well, yes, but...  I think there should be an ABC for "file-like",
> which the standard "file" and "StringIO" implementations inherit from.
> This could even be a fourth PEP.

PEP 3116 already documents ABCs like RawIOBase, BufferedIOBase,
TextIOBase. (It needs to be updated; the implementation adds a fourth,
the base of them all, IOBase.)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list