None in string formatting

Erik Max Francis max at alcyone.com
Tue Mar 8 23:30:24 EST 2005


rodney.maxwell at gmail.com wrote:

> Was doing some string formatting, noticed the following:
> 
>>>> x = None
>>>> "%s" % x
> 'None'
> 
> Is there a reason it maps to 'None'? I had expected ''.

Because %s just calls str on the arguments, and str(None) == 'None'.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   As far as I'm concerned, being any gender is a drag.
   -- Patti Smith



More information about the Python-list mailing list