Python paradigms

Andrew Dalke dalke at
Sat Apr 8 21:06:17 EDT 2000

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

More information about the Python-list mailing list