Python complaints

Quinn Dunkan quinn at krone.ugcs.caltech.edu
Wed Dec 15 15:58:25 EST 1999


On Wed, 15 Dec 1999 18:54:04 GMT, choffman at dvcorp.com <choffman at dvcorp.com>
wrote:
>In article <38576B73.59C7BA85 at udel.edu>,
>  Charles Boncelet <boncelet at udel.edu> wrote:
>
>>
>> I think all functions that operate on single things should be able to
>> operate on a list of things and return a list of things. (Are there
>> obvious reasons why this paradigm can't work?) Consider,
>
>Ignoring the suggestion that 'len' itself be changed, if you truly mean
>the language should automatically loop over lists, then there is
>certainly an obvious reason why this can't work.

Maybe it's just me, but I think that:
map(sin, [1, 2, 3])
is explicit and clear and already works.  Wheras modifying built in functions
so that some take lists makes things unclear unless the reader knows about
that 'feature' of that function.  And in the time it takes to read the docs to
find out if this is one of those special functions you could have just written
a map or loop anyway.

Even though python gives you the power to have functions try to figure out
what to do based on the type of their arguments, be careful with it.  I think
there's a lot to be said for functions which take only one type of arg and do
one well defined thing with it.  Especially in the builtins.  Trying to make
functions too smart is more trouble that it's worth, IMHO.

    Explicit is better than implicit.
        Tim 14:10

(ok, so I don't remember the msg id...)



More information about the Python-list mailing list