[Python-3000] Need help completing ABC pep

Bill Janssen janssen at parc.com
Fri Apr 20 21:07:04 CEST 2007


Guido,

A good start.  A few comments:

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?

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.

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()".

> Python will not require that a class derives from BasicMapping or
> Sequence when it defines a __getitem__ method,

Good.

> nor will the x[y] syntax require that x is an instance of either ABC.

Good.

> 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.

Bill


More information about the Python-3000 mailing list