Python paradigms

Chuck Esterbrook echuck at
Sat Apr 8 22:00:58 EDT 2000

Andrew Dalke wrote:

> Me:
> >>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.
>                     Andrew
>                     dalke at

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 mailing list