
castironpi at gmail
May 20, 2008, 6:35 AM
Post #5 of 5
(96 views)
Permalink
|
|
Re: test mult vars to same value, how to shorten expr?
[In reply to]
|
|
On May 20, 2:08 am, Peter Otten <__pete...@web.de> wrote: > notnorweg...@yahoo.se wrote: > > if i want o test: > > if a == 5 and b ==5 and c==5 ... z==5 > > > is there some synctactic suagr for this? > > > rather than maiking one of my own i mean, something built-in like: > > if a,b,c... z == 5: > > if all(x == 5 for x in a,b,c,...): > print "yep" > > Peter >>> a,b,c,d=5,5,5,5 >>> import functools >>> import operator >>> myequals= functools.partial( operator.eq, 5 ) >>> map( myequals, ( a, b, c, d ) ) [True, True, True, True] >>> all( _ ) True -- http://mail.python.org/mailman/listinfo/python-list
|