Short if

Heather Coppersmith me at privacy.net
Wed Jul 7 16:20:56 CEST 2004


On Wed, 7 Jul 2004 15:08:38 +0200,
"Vincent Wehren" <vwehren at home.nl> wrote:

> class Klass:
>   def __init__(self, a, b, foo=None, bar=None):

>       self.a = a
>       self.b = b
>       self.foo = (foo, someDefaultMutable)[foo is None]
>       self.bar = (bar, someOtherDefaultMutable)[bar is None]

    self.foo = foo or someDefaultMutable
    self.bar = bar or someOtherDefaultMutable

Regards,
Heather

-- 
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli



More information about the Python-list mailing list