473,656 Members | 2,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

strange test for None

in my server i use the following piece of code:

ims = self.headers["if-modified-since"]
if ims != None:
t = int(ims)

and i'm always getting the following error:

t = int(ims)
ValueError: invalid literal for int(): None

i wanna know what the hell is going on... first i tried to test using
is not None, but it makes no difference.

Feb 3 '07 #1
4 1624
forgot to mention my interpreter version: 2.4.4

Feb 3 '07 #2
"karoly.kiripol szky" <ka************ ****@gmail.comw rote in
news:11******** **************@ m58g2000cwm.goo glegroups.com:
in my server i use the following piece of code:

ims = self.headers["if-modified-since"]
if ims != None:
t = int(ims)

and i'm always getting the following error:

t = int(ims)
ValueError: invalid literal for int(): None

i wanna know what the hell is going on... first i tried to test
using is not None, but it makes no difference.
It appears that ims is the string 'None', so it fails the test, but
is an invalid literal.

--
rzed
Feb 3 '07 #3

On Feb 3, 2007, at 7:47 AM, karoly.kiripols zky wrote:
in my server i use the following piece of code:

ims = self.headers["if-modified-since"]
if ims != None:
t = int(ims)

and i'm always getting the following error:

t = int(ims)
ValueError: invalid literal for int(): None

i wanna know what the hell is going on... first i tried to test using
is not None, but it makes no difference.
Sounds like ims == 'None'. Try changing:

if ims != None:

to

if ims:

and you might also wrap your call to int(ims) in a try block.

HTH,
Michael
Feb 3 '07 #4
the tested variable was really a string containing "None" instead of
simply None. this is the first time i ran into this error message
confusion. :)

thanks for the help!

On Feb 3, 6:29 pm, Michael Bentley <rmc...@gmail.c omwrote:
On Feb 3, 2007, at 7:47 AM, karoly.kiripols zky wrote:
in my server i use the following piece of code:
ims = self.headers["if-modified-since"]
if ims != None:
t = int(ims)
and i'm always getting the following error:
t = int(ims)
ValueError: invalid literal for int(): None
i wanna know what the hell is going on... first i tried to test using
is not None, but it makes no difference.

Sounds like ims == 'None'. Try changing:

if ims != None:

to

if ims:

and you might also wrap your call to int(ims) in a try block.

HTH,
Michael

Feb 3 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2044
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 TestCase.skipIf(expr, msg): skips if expr is true These can be called either in setUp() or in the test methods. I also added reporting of skipped tests to TestResult, _TextTestResult and
6
1767
by: Graeme Wood | last post by:
I have an ASP page hosted on a windows 2003 server. This page was working fine until Saturday. Now, the server doesn't serve it and gives a 404 page not found error. The file DEFINITELY exists in the correct folder (it worked fine previous to now). I have tested the page on our in house server, which is a Windows 2000 server and the page works fine. I have exported the database data and tables which are necessary to the 2000 server and...
7
1658
by: M O J O | last post by:
Hi, I'm developing a asp.net application and ran into a strange css problem. I want all my links to have a dashed underline and when they are hovered, it must change to a solid line. Sounds simple, but it's not working. I've cooked down my output code to show you what I mean. If you run the code below, there's no line under the link, but if you either remove the
5
6644
by: Adam Kucharski | last post by:
Hello !!! IBM AIX 5.1 DB2 UDB WSE v.8.1.4 (with FP4) (Polish) DiagLevel 4 Client: Windows XP (Polish) Problem: 2003-12-17-17.58.50.853952 Instance:db2inst1 Node:000 PID:33528(db2tcpcm) TID:1 Appid:none
3
2849
by: Jim Irvine | last post by:
I have a small database made up of 2 tables. I have a report that is driven from a query. On the report are a couple of fields linked to memo boxes in the table. Everytime I run the report I get the following strange characters instead of data. �_ Ἃ These actually show us as square boxes and capital A's with a tilde etc.
20
1666
by: SpreadTooThin | last post by:
I have a list and I need to do a custom sort on it... for example: a = #Although not necessarily in order def cmp(i,j): #to be defined in this thread. a.sort(cmp) print a
2
297
by: karoly.kiripolszky | last post by:
in my server i use the following piece of code: ims = self.headers if ims != None: t = int(ims) and i'm always getting the following error: t = int(ims) ValueError: invalid literal for int(): None
13
10378
by: Jen | last post by:
One user of my application is experiencing an exception "input string not in correct format". But it makes no sense where it is occurring. It is occurring when a string from a textbox ("172") is being convert to an Int16 (using Convert.ToInt16). How can that be? There are other text boxes that are used in the identical fashion and they don't generate the exception. All there are many other machines running my application that don't...
0
1200
by: Gwl | last post by:
I made some test to mesure the c# read perfomance on binary file and I made some curious discovery. Except for some minor details, the following is the code I used to read the file: byte buffer = new byte; FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None, fileStreamBufferSize, fileOptions); BinaryReader stream = new BinaryReader(fileStream);
112
4656
by: Prisoner at War | last post by:
Friends, your opinions and advice, please: I have a very simple JavaScript image-swap which works on my end but when uploaded to my host at http://buildit.sitesell.com/sunnyside.html does not work. To rule out all possible factors, I made up a dummy page for an index.html to upload, along the lines of <html><head><title></title></ head><body></body></html>.; the image-swap itself is your basic <img src="blah.png"...
0
8380
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8598
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7310
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.