[EMAIL PROTECTED] 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 ''.

Can you explain why you expected that? A few other examples that make me not expect what you do:


py> '%s' % False
'False'
py> '%s' % []
'[]'
py> '%s' % {}
'{}'
py> '%s' % set()
'set([])'

All of the objects above evaluate to False in a boolean context like '' does, but they display a string appropriate to their type. Since None has it's own type (NoneType), I would expect similar behavior.

STeVe
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to