473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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 1614
forgot to mention my interpreter version: 2.4.4

Feb 3 '07 #2
"karoly.kiripolszky" <ka****************@gmail.comwrote in
news:11**********************@m58g2000cwm.googlegr oups.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.kiripolszky 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.comwrote:
On Feb 3, 2007, at 7:47 AM, karoly.kiripolszky 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
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...
6
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...
7
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...
5
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...
3
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...
20
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
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...
13
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...
0
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...
112
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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...

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.