I come to praise .join, not to bury it...

Alex Martelli aleaxit at yahoo.com
Tue Apr 17 08:47:22 EDT 2001


"Russell E. Owen" <owen at astrono.junkwashington.emu> wrote in message
news:9b77ln$pbe$1 at nntp6.u.washington.edu...
> >It would take little to write a collection class, but making
> >_types_ (as opposed to _classes_) "inherit" from a class would
> >require major surgery to Python.  As things stand, types just do
> >not "inherit".  Lists, strings, Unicode strings, tuples,
> >dictionaries and arrays (in standard module array) are all
> >types.
>
> Thanks. I realized that later when thinking more about it. Thanks for
> the helpful reference (elided; read Alex's message) to PEP 246. It
> sounds very helpful in this context.

I agree that PEP 246 would be VERY helpful:-).


> >> - the % operator could work on any kind of collection; I occasionally
> >> try to use a list instead of a tuple
> >
> >That would break existing code:
> >
> >>>> print "ba%sbo"%range(2)
> >ba[0, 1]bo
>
> Fascinating. I thought this was deprecated if not already illegal, as
> remember reading a threat to insist that % always have a tuple (or dict)

Oh?  An URL to a reference to this 'deprecation' would be welcome.

It would make sense if it were so (eventually and gradually letting
any sequence or mapping take the role of a tuple or dictionary
respectively) but I never heard of such deprecation.

> to the right of it. Has that been rescinded? (Did I misread something?).
> I'd already reluctantly changed my coding style to accomodate the
> change. It's certainly tempting to leave out the (,) when one has a
> single item to print, and if this is Approved Style then I'm not going
> to cry over lists and list-like items needing a tuple() around them to
> act as tuples.

I could live with either situation, too -- but I'd like some
official info that the current "% accepts any RHS" situation
is going to change, before I start "(x,)"ing around:-).


Alex






More information about the Python-list mailing list