Some Python 2.1 ideas

Alex Martelli aleaxit at yahoo.com
Sun Dec 24 17:30:30 EST 2000


"Thomas Wouters" <thomas at xs4all.net> wrote in message
news:mailman.977688488.25438.python-list at python.org...
    [snip]
> > > Wouldn't it be cleaner to enhance the file object with additional
> > > methods:
> > >
> > >   f. readline_chomp()
> > >   f.readlines_chomp()
>
> > This would be a good idea, except it wouldn't fit with the standard
Python idiom
> > for reading files:
>
> And everything that poses as a file object would have to duplicate those
> functions, all of a sudden. Guido is pretty conservative in adding
> conveniency functions to builtin (and oft-imitated) objects because of
that.

A mixin-class (implementing, e.g., readline_chomp in terms of .readline
and chomp, in this case) could also be supplied to ease the task of
'emulating convenience-methods'.  Not crucial in this case (the proposed
methods appear somewhat marginal), but an approach that might help
in other cases, I think.


Alex






More information about the Python-list mailing list