Re: default value in list comprehension

2010-04-19 Thread Bruno Desthuilliers
eb303 a écrit : On Apr 19, 2:20 pm, AlienBaby wrote: Hi, just a quick one, Is it possible to achieve a default value in a list comprehension where the if-clause is false? Ie, something similar to: [ a for a in b if something(a) else 'default' ] the idea being that, rather than skip a value

Re: default value in list comprehension

2010-04-19 Thread AlienBaby
On Apr 19, 1:23 pm, eb303 wrote: > On Apr 19, 2:20 pm, AlienBaby wrote: > > > > > > > Hi, > > > just a quick one, > > > Is it possible to achieve a default value in a list comprehension > > where the if-clause is false? > > > Ie, something similar to: > > > [ a for a in b if something(a) else 'de

Re: default value in list comprehension

2010-04-19 Thread eb303
On Apr 19, 2:20 pm, AlienBaby wrote: > Hi, > > just a quick one, > > Is it possible to achieve a default value in a list comprehension > where the if-clause is false? > > Ie, something similar to: > > [ a for a in b if something(a) else 'default' ] > > the idea being that, rather than skip a value

default value in list comprehension

2010-04-19 Thread AlienBaby
Hi, just a quick one, Is it possible to achieve a default value in a list comprehension where the if-clause is false? Ie, something similar to: [ a for a in b if something(a) else 'default' ] the idea being that, rather than skip a value if the if-clause is false, to place a default value at t