On Oct 24, 8:02 am, [EMAIL PROTECTED] wrote:
> On Oct 24, 7:09 am, Alexandre Badez <[EMAIL PROTECTED]> wrote:
>
> > I'm just wondering, if I could write a in a "better" way this code
>
> > lMandatory = []
> > lOptional = []
> > for arg in cls.dArguments:
> >   if arg is True:
> >     lMandatory.append(arg)
> >   else:
> >     lOptional.append(arg)
> > return (lMandatory, lOptional)
>
> > I think there is a better way, but I can't see how...
>
> You might look into list comprehensions. You could probably do this
> with two of them:
>
> <code>
> # completely untested
> lMandatory = [arg for arg in cls.dArguments if arg is True]
> lOptional  = [arg for arg in cls.dArguments if arg is False]
> </code>
>
> Something like that. I'm not the best with list comprehensions, so I
> may have the syntax just slightly off. See the following links for
> more information:
>
> http://www.secnetix.de/olli/Python/list_comprehensions.hawkhttp://docs.python.org/tut/node7.html
>
> Mike

After reading the others replies, it makes me think that I'm barking
up the wrong tree. Ah well.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to