Python paradigms

Andrew Dalke dalke at acm.org
Sat Apr 8 14:24:36 EDT 2000


Nick Maclaren wrote
>    x = (a != NULL ? a[i]->weeble : 0) + (b != NULL ? b[i]->wombat : 0)
> [...]
>What paradigms are there for replacing such constructions by?


How about

  x = getattr(a, "weeble", 0) + getattr(b, "wombat", 0)

  ?

                    Andrew
                    dalke at acm.org






More information about the Python-list mailing list