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: 4 908 no**********@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:
How about :
if 5 == a == b == c == ... z:
...
--Scott David Daniels Sc***********@Acm.Org
On Mon, 19 May 2008 20:36:45 -0700, notnorwegian 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:
Since Python 2.5 there's `all()`:
In [81]: a, b, c, d = 5, 5, 5, 6
In [82]: all(x == 5 for x in (a, b, c))
Out[82]: True
In [83]: all(x == 5 for x in (a, b, c, d))
Out[83]: False
Ciao,
Marc 'BlackJack' Rintsch no**********@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
On May 20, 2:08*am, Peter Otten <__pete...@web.dewrote:
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Remy Blank |
last post by:
Ok, here we go.
I added the possibility for tests using the unittest.py framework
to be skipped. Basically, I added two methods to TestCase:
TestCase.skip(msg): skips unconditionally...
|
by: lawrence |
last post by:
Is this the correct way to test for a method before I use it?
createRange() is, I believe, an IE only method.
function wrapSelectionInTag(selection, tag) {
if (document.selection.createRange)...
|
by: gokkog |
last post by:
Hi there,
There's a classic hash function to hash strings, where MULT is defined
as "31":
//from programming pearls
unsigned int hash(char *ptr)
{ unsigned int h = 0;
unsigned char *p =...
|
by: GaryDean |
last post by:
I have serveral applications now running that are using the
MembershipProvider classes and they are each using their own security tables
in SQL Server 2005 instead of the express databases - they...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| | |