On 14 Jul 2005 19:25:41 -0700, "Nicolas Couture" <[EMAIL PROTECTED]> wrote:
>Hi, > >Is it possible to generate a list of `None' ? > >opts.__dict__.values() below could be represented by [None, None, None] > >--- >def get_options(opts): > """Return True or False if an option is set or not""" > vals = opts.__dict__.values() > > for val in vals: > if val is not None: > return True > > return False >--- > >This is how I'd like to see it: > >--- >def get_options(opts): > """Return True or False if an option is set or not""" > vals = opts.__dict__.values() > > for if vals is [None * len(vals)]: > return False > > return True >--- how about (untested) def get_options(opts): """Return True or False if an option is set or not""" return [1 for val in vars(opts).values() if val is not None] and True or False Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list