Why does list have no 'get' method?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Thu Feb 7 03:20:52 EST 2008


Paul Rubin:
> I like the suggestion, except it should be
>      port = int(sys.argv.get(1, '8000'))
> one could imagine your example going wrong in a protocol where 0 is
> a valid port number.

I think a high-level language like Python must have boolean operators
(or and not) that behave in a much more clean way, with a simpler
semantics. That is they have to return only true or false. Otherwise
they are just a source of bugs and confusion. This is a change fit for
Python 3.
That trick with or/and may look good for Perl, but it's unfit for a
language that tries to be clear, readable from people that don't know
it much, and good to learn to program. Python has now the if-then
expression too that is more clear.

Bye,
bearophile



More information about the Python-list mailing list