strange test for None

rzed rzantow at gmail.com
Sat Feb 3 09:35:42 EST 2007


"karoly.kiripolszky" <karoly.kiripolszky at gmail.com> wrote in
news:1170510427.981922.170100 at m58g2000cwm.googlegroups.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



More information about the Python-list mailing list