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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 12th, 2002, 09:27 AM
nickname nickname is offline
inexperienced and useless
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Stevenage, uk
Posts: 10 nickname User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
do i need to define something that a value is already defined to?

I have a cgi and i have managed to get the radio buttons working, and can print their value. Eg the button is searchtype and it's value could be substructure.
So when I write:
print searchtype
substructure is printed.

However if I type:
if searchtype == substructure:
Print "the search is substructure"

I get an error saying that substructure is not defined, how do I get around this does anyone know?

Cheers,

NiCkNaMe

Reply With Quote
  #2  
Old March 13th, 2002, 05:07 PM
ZeUs's Avatar
ZeUs ZeUs is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: St. George, Utah
Posts: 63 ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 31
Do this instead:

Code:
if searchtype == "substructure": 
    print "the search is substructure"


If you don't have quotes around "substructure," Python thinks that it is a variable name and tries to look up the value of it to compare with the value of searchtype. As there is no variable "substructure" defined, you get an error. Putting quotes around it makes it a string literal.
__________________
Lucas Marshall

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > do i need to define something that a value is already defined to?


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 6 hosted by Hostway