copysort patch, was RE: [Python-Dev] inline sort option

Alex Martelli aleaxit at yahoo.com
Sat Oct 18 16:24:33 EDT 2003


On Saturday 18 October 2003 07:18 pm, Nick Coghlan wrote:
> Alex Martelli strung bits together to say:
> >>    Guido>   keys = D.keys()
> >>    Guido>   keys.sort()
> >>    Guido>   for key in keys:
> >>    Guido>       ...
> >>
> >>Current standard practice is also fine.
> >
> > Nolo contendere.  It DOES feel a bit like boilerplate, that's all.
>
> Hi,
>
> While I'm not an active Python contributor (yet), I've been lurking on
> python-dev since March.

Hi Nick!

> Something was bugging me about the whole l.copysort() ('sortedcopy'?) idea.
> For whatever reason, the above comment crystalised it - if there's going to
> be a special 'sortedcopy' to allow minimalist chaining, then what about
> 'reversedcopy' or 'sortedreversedcopy', or any of the other list methods
> that may be considered worth chaining?

sort has just (in CVS right now) sprouted an optional reverse=True parameter
that makes sort-reverse chaining a non-issue (thanks to the usual 
indefatigable Raymond, too).

But, for the general case: the BDFL has recently Pronounced that he does 
not LIKE chaining and doesn't want to encourage it in the least.  Yes, your
trick does allow chaining, but the repeated chain(...) calls are cumbersome
enough to not count as an encouragement IMHO;-).

A generalized wrapping system that wraps all methods so that any
"return None" is transformed into a "return self" WOULD constitute
encouragement, and thus a case of Lese BDFLity, which would easily
risk the wrath of the PSU (of COURSE there ain't no such thing!)...


Alex




More information about the Python-Dev mailing list