Different "look and feel" of some built-in functions
Dieter Maurer
dieter at handshake.de
Sat Sep 25 12:26:21 EDT 2021
Stefan Ram wrote at 2021-9-24 16:48 GMT:
>"Dieter Maurer" <dieter at handshake.de> writes:
>>A list is ordered. Therefore, it is important where
>>in this order an element is added. Thus, for a list,
>>`append` is a better name than `add` -- because it already
>>tells us in the name where it adds the new element.
>
> In a collection of texts, which is not large but mixed from
> many different fields and genres, I find (using a Python
> script, of course) eight hits for "added to the list" :
>
>|s and rock n roll can be added to the list. As - Taylor, 2012
>| of opinion was probably added to the list tow - from a dictionary
>|gg and his wife might be added to the list of - Sir Walter Scott
>|ships when your name was added to the list. In - Percy Bysshe Shelley
>|em that wealth should be added to the list. No - Henry
>|n was discovered and was added to the list of - from a dictionary
>|nd said his name must be added to the list, or - Mark Twain
While a list is ordered,
applications using a list may not be interested in the particular
order and thus just speak of "add to the list"
rather than "append to the list".
Nevertheless, I find the name `append` far better than `add` for
the list type - because it describes better what it is doing.
I am a big fan of "speaking names".
> . There was no hit for "appended to the list".
>
> When one says "add something to a list", it is usually understood
> that one adds it at the /end/. In the case of traditional written
> lists it is not possible in any other way.
Really? Prepending should be as possible as appending
(if one disregards implementation details).
--
Dieter
More information about the Python-list
mailing list