Why is str(None) == 'None' and not an empty string?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Wed Aug 28 08:21:37 EDT 2013
On Wed, 28 Aug 2013 01:57:16 -0700, Piotr Dobrogost wrote:
> Hi!
>
> Having repr(None) == 'None' is sure the right thing but why does
> str(None) == 'None'? Wouldn't it be more correct if it was an empty
> string?
Why do you think an empty string is more correct? Would you expect
str([]) or str(0.0) or str({}) to also give an empty string?
I can't see any reason for str(None) to return the empty string.
--
Steven
More information about the Python-list
mailing list