Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 31st, 2004, 10:25 AM
SaxMan101 SaxMan101 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 6 SaxMan101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
If statement evaluation problem

In the If statement below, the criteria always evaluates to false in running code. If I paste the criteria in the immediate window and hit enter, it evaluates to true. The Coils object is an ADODB recordset connected to a DB/2 database (i think...its our AS400 Business system). I've also tried float(u'10') on the right side of the operator, but that doesn't work either (in the running code. any of this works in the immediate window). Any ideas on whats wrong?

Code:
if (float(self.Coils.Fields("csbfnb").Value) >= float(10)):
      self.Inventory.Fields("width").Value = float(self.Coils.Fields("csb6nr").Value)
else:                            
      self.Inventory.Fields("width").Value = float(self.Coils.Fields("csbfnb").Value)

Reply With Quote
  #2  
Old May 31st, 2004, 11:21 AM
SaxMan101 SaxMan101 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 6 SaxMan101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Nevermind. I'm not sure what I was doing wrong before, but if i put float(u'10') on the right side, it works.

Reply With Quote
  #3  
Old May 31st, 2004, 12:31 PM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,254 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 8 h 9 m
Reputation Power: 265
Instead of float(10) or float(u'10') you could just use 10.0.

However, are you sure the type of Coils.Fields("csbfnb").Value is a float? If it was a string, the comparision would still work, but a string always compares as greater than a float.

Dave - The Developers' Coach

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > If statement evaluation problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT