Hi,
I have a if..else statement in my script. The statements all execute
fine, but the problem is , even if the IF part of the statement is
true, the else part executes as well. The verion of pythin i use 2.5
Any help is appreciatiated.
Regards
Big Den. 5 1650
bigden007 wrote:
I have a if..else statement in my script. The statements all execute
fine, but the problem is , even if the IF part of the statement is
true, the else part executes as well. The verion of pythin i use 2.5
Any help is appreciatiated.
You're doing something wrong. Without seeing actual code, it's
impossible to say what.
--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis
So little time, so little to do.
-- Oscar Levant
Your else statement is incorrectly indented. The interpreter treats it
as part of the for-loop construct inside the if statement rather than as
part of the if statement itself. See the recent thread about for-else
constructs for more details.
If your problem is not obvious yet, make sure you aren't mixing spaces
and tabs.
:)
bigden007 wrote:
Hi,
I have a if..else statement in my script. The statements all execute
fine, but the problem is , even if the IF part of the statement is
true, the else part executes as well. The verion of pythin i use 2.5
Any help is appreciatiated.
Regards
Big Den.
Works as expected here, the 'else' part is not executed if the 'if' part is
true.
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>def tr():
.... print "tr func"
.... return "Sander"
....
>>def fa():
.... print "fa func"
.... return "Harry"
....
>>s = "yes" if tr() == "Sander" else fa()
tr func
>>s
'yes'
>>s = "yes" if tr() == "San" else fa()
tr func
fa func
>>s
'Harry'
>>>
Can you show your code?
bigden007 wrote:
>
Hi,
I have a if..else statement in my script. The statements all execute
fine, but the problem is , even if the IF part of the statement is
true, the else part executes as well. The verion of pythin i use 2.5
Any help is appreciatiated.
Regards
Big Den.
-- http://mail.python.org/mailman/listinfo/python-list
--
View this message in context: http://www.nabble.com/if..else-stmt-...html#a13340589
Sent from the Python - python-list mailing list archive at Nabble.com.
bigden007 wrote:
Hi,
I have a if..else statement in my script. The statements all execute
fine, but the problem is , even if the IF part of the statement is
true, the else part executes as well. The verion of pythin i use 2.5
Any help is appreciatiated.
Regards
Big Den.
Your else statement is incorrectly indented. The interpreter treats it
as part of the for-loop construct inside the if statement rather than as
part of the if statement itself. See the recent thread about for-else
constructs for more details.
If your problem is not obvious yet, make sure you aren't mixing spaces
and tabs.
:)
bigden007 a écrit :
Hi,
I have a if..else statement in my script. The statements all execute
fine, but the problem is , even if the IF part of the statement is
true, the else part executes as well. The verion of pythin i use 2.5
Any help is appreciatiated.
My crystal ball tells me the problem is on line 42 !-)
And if you expect any useful help, please post the minimal working code
reproducing the problem (chances are you'll find the problem by yourself
doing so...). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John |
last post by:
Hi all,
I am doing the change from having worked in Oracle for a long time to
MS SQL server and am frustrated with a couple of simple SQL stmt's. Or
at least they have always been easy.
The...
|
by: claus.hirth |
last post by:
I wrote a stored procedure that uses a prepared INSERT INTO statement
in order to play with the PREPARE and EXECUTE keywords.
In transcript 1 below the call to that stored procedure does not...
|
by: don.fleming |
last post by:
Hi folks: Am doing a VBA SQL Select stmt with multiple rows found and
not getting RecordCount > 1. I've verified there are multiple rows
found by copying my SQL stmt from Debug window and pasting...
|
by: Uzytkownik |
last post by:
I've some function:
function show($id) {
$title = $text = $date = $nick = NULL;
$stmt = $this->base->stmt_init();
$stmt->prepare("SELECT title,text,datetime,nick FROM posts LEFT JOIN authors ON...
|
by: seshu |
last post by:
Hi everybody
Presently Iam write three select statements with diff where and limt conditions but the select stmt in them is same insted of that can i write only one direct stmt...
|
by: jesmi |
last post by:
hi all
i have a problem with my code.following is my code:
Connection con = null;
PreparedStatement stmt = null;
|
by: Kingsly |
last post by:
How to read "stmt" column of "sysibm.syspackstmt" table in a readable format?
select stmt from sysibm.syspackstmt where name like 'MYPROC1';
I was expecting the stored procedure statements as...
|
by: pankaj17 |
last post by:
hello everyone,
MYSQL query ............
how to set prepare stmt result in variable
i have written prepare stmt in store procedure and i want to set result of prepare stmt in variable
...
|
by: pankaj17 |
last post by:
hello everyone,
MYSQL query ............
how to set prepare stmt result in variable
i have written prepare stmt in store procedure and i want to set result of prepare stmt in variable
...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |