Why does list have no 'get' method?
Arnaud Delobelle
arnodel at googlemail.com
Thu Feb 7 05:35:01 EST 2008
On Feb 7, 8:20 am, bearophileH... at lycos.com wrote:
> 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
Personally, between
* foo if foo else bar
* foo or bar
I prefer the second. Maybe it could be spelt
* foo else bar ?
Moreover between the following two:
* foores = foo()
foobar = foores if foores else bar
* foobar = foo() or bar
I also prefer the second. Maybe it could be spelt
* foo() else bar ?
I have not thought of parsing issues :)
--
Arnaud
More information about the Python-list
mailing list