Python paradigms

Nick Maclaren nmm1 at cus.cam.ac.uk
Sat Apr 8 18:40:11 EDT 2000


In article <8cntqp$upi$1 at slb0.atl.mindspring.net>,
Andrew Dalke <dalke at acm.org> wrote:
>
>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)

Thank you, yes, that does deal with that specific example.  But
it does not extend to the general case.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1 at cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



More information about the Python-list mailing list