echuck at mindspring.com
Sun Apr 9 04:00:58 CEST 2000
Andrew Dalke wrote:
> >>How about
> >> x = getattr(a, "weeble", 0) + getattr(b, "wombat", 0)
> Nick Maclaren:
> >Thank you, yes, that does deal with that specific example. But
> >it does not extend to the general case.
> Ahh, I thought the general case was "test if something exists
> and, if so, get data from it, otherwise use a given value."
> What is the general case you are interested in - that of C's
> ternary ?: operator? I've rarely missed it, because most of
> the subcases are handled by things like getattr.
> dalke at acm.org
I miss ?: and in fact, find myself writing extra if-else statements because of it. I think ?: is a pretty natural construct.
Maybe Python 3K....
More information about the Python-list