Pre-PEP: reverse iteration methods

Stephen Horne $$$$$$$$$$$$$$$$$ at $$$$$$$$$$$$$$$$$$$$.co.uk
Wed Sep 24 02:20:58 EDT 2003


On Wed, 24 Sep 2003 04:44:21 GMT, "Andrew Dalke"
<adalke at mindspring.com> wrote:

>-1 from me.  'backwards' looks to me like something which changes
>the list ordering in place, like what 'reverse' does.  Or something
>which returns a new list but in reverse order.  It's an adjective,
>when it should be a verb.

I disagree with this. IMO something that modifies a value in place
should be named using a verb (such as reverse, or sort, or update...).
Something that returns a value without modifying its parameters/object
should be named to describe what it returns - normally a noun or
adjective (such as globals, len, isinstance).

So if we had a sorting function that returns a sorted version of the
parameter without modifying its parameter, I'd want it to be called
'sorted' as opposed to the current in-place 'sort'.

Of course there are non-modifying functions that are named as verbs
(map, filter and reduce being particularly obvious), but that does
seems slightly wrong to me - though for the ones I've listed there is
basically an overriding convention (they are well known names).


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk




More information about the Python-list mailing list