Jojo Mwebaze jojo.mweb...@gmail.com wrote
i would like to implement the following in lists
assuming
x = 3
y = 4
z = None
i want to create a dynamic list such that
mylist = [ x , y, z ] , if z in not None
if z is None then
mylist = [x,y]
Assuming you actually mean that you don;t want
Jojo Mwebaze wrote:
Hi There,
i would like to implement the following in lists
assuming
x = 3
y = 4
z = None
i want to create a dynamic list such that
mylist = [ x , y, z ] , if z in not None
if z is None then
mylist = [x,y]
Anyhelp!
cheers
Jojo
Jojo Mwebaze wrote:
Hi There,
i would like to implement the following in lists
assuming
x = 3
y = 4
z = None
i want to create a dynamic list such that
mylist = [ x , y, z ] , if z in not None
if z is None then
mylist = [x,y]
Anyhelp!
cheers
Jojo
Are there any constraints on x
Thanks to everyone, nice ideas!
cheers
On Wed, Mar 3, 2010 at 10:02 AM, Christian Witts cwi...@compuscan.co.zawrote:
Jojo Mwebaze wrote:
Hi There,
i would like to implement the following in lists
assuming
x = 3
y = 4
z = None
i want to create a dynamic list such that
mylist = [ x
Dave Angel wrote:
Jojo Mwebaze wrote:
Hi There,
i would like to implement the following in lists
assuming
x = 3
y = 4
z = None
i want to create a dynamic list such that
mylist = [ x , y, z ] , if z in not None
if z is None then
mylist = [x,y]
Anyhelp!
cheers
Jojo
Are there any
On Wed, 3 Mar 2010 07:46:39 pm Alan Gauld wrote:
mylist = [irtem for item in aList where item != None]
Comparisons with None almost always should be one of:
item is None
item is not None
The reason is that item is None is ONLY ever true if the item actually
is the singleton object None
On Thu, 4 Mar 2010 05:18:40 am Alan Gauld wrote:
Steven D'Aprano st...@pearwood.info wrote
Comparisons with None almost always should be one of:
item is None
item is not None
Yes, but the reason I changed it (I originally had is not) is that
!= is a more general test for illustrating
Steven D'Aprano st...@pearwood.info wrote
List comps can include *any* comparison:
[x+1 for x in data if (3*x+2)**2 100*x or x -5]
Sure, but the wording suggested (maybe wrongly) that the OP
was a real beginner and so the concept of an expression
was likely to be foreign. Sticking with