Python's simplicity philosophy

Ben Finney bignose-hates-spam at and-benfinney-does-too.id.au
Fri Nov 21 01:43:03 CET 2003


On 21 Nov 2003 00:29:09 +0100, Curt wrote:
> Erik Max Francis <max at alcyone.com> writes:
>> In your sample, there were no consecutive lines that were identical,
>> so uniq did nothing.  Change the order of them, and despite still
>> being non-sorted, you'll see that uniq is working:
> 
> Well, changing the order of the lines in my sample to ensure the
> contiguity of identical entries _is_ sorting.

Erik wasn't talking about the *process* of rearranging lines; he was
talking about the *state* of the input list.

This list is sorted (in ascending alphanumeric order):

    curty
    curty
    flirty
    flirty

This list is not sorted:

    flirty
    curty
    curty
    flirty

Both contain contiguous identical lines.  The 'uniq' filter will have an
effect on oth these lists.


This list is sorted:

    cooty
    curty
    flippy
    flirty

This list is not sorted:

    flippy
    curty
    cooty
    flirty

Neither contain contiguous identical lines.  The 'uniq' filter will not
have an effect on either of these lists.

> "non-sorted" appears to me to be a rather provocative description of
> the modified sample which you were constrained to alter in order that
> it meet a criterion whose existence you deny.

The criterion has been stated several times already: uniq will act on
consecutive identical lines.  As shown above, this property is
orthogonal to "sorted".

It's unfortunate (and probably worthy of a bug report) that man pages
refer to "sorted" in the 'NAME' section for 'uniq', because the sorted
or non-sorted state is unrelated to the behaviour of 'uniq'.

-- 
 \    "Anything that is too stupid to be spoken is sung."  -- Voltaire |
  `\                                                                   |
_o__)                                                                  |
Ben Finney <http://bignose.squidly.org/>




More information about the Python-list mailing list