first of not None

Serge Matveenko serge at matveenko.ru
Thu Oct 9 03:07:32 EDT 2008


Hello, everybody!

Could someone help me with coding this thing?

I need to put in the var property of the first object from the list
that is not None. Somth like:

foo = first_of([any, beny, riki,]).name

Dont want to ugly if-cascade:

foo = any.name if name is not None else beny.name if beny is not None \
else riki.name if riki is not None


-- 
Serge Matveenko
mailto:serge at matveenko.ru
http://serge.matveenko.ru/



More information about the Python-list mailing list