Re: Generating a list of None

2005-07-16 Thread Bengt Richter
On 16 Jul 2005 02:31:28 -0700, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: >[Bengt Richter] >> 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 Fa

Re: Generating a list of None

2005-07-16 Thread Raymond Hettinger
[Bengt Richter] > 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 While we're tossing around hacks and coding atrocities, we should note that:

Re: Generating a list of None

2005-07-15 Thread Bengt Richter
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""" >

Re: Generating a list of None

2005-07-14 Thread Dan Sommers
On 14 Jul 2005 19:28:14 -0700, "Nicolas Couture" <[EMAIL PROTECTED]> wrote: > if vals == [None * len(vals)]: if vals == [None] * len(vals): Regards, Dan -- Dan Sommers -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating a list of None

2005-07-14 Thread Nicolas Couture
of course the later snipplet should be: --- def get_options(opts): """Return True or False if an option is set or not""" vals = opts.__dict__.values() if vals == [None * len(vals)]: return False return True --- -- http://mail.python.org/mailman/listinfo/python-list