473,503 Members | 1,656 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 1619
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
2024
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
1757
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
1651
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
6634
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
2844
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
1648
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...
13
10360
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
1184
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
4584
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
7198
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
7319
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...
1
6979
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...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3160
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...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.