Re: Why is str(None) == 'None' and not an empty string?

2013-08-29 Thread Ian Kelly
On Wed, Aug 28, 2013 at 6:21 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: 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

Re: Rép : Why is str(None) == 'None' and not an empty string?

2013-08-29 Thread Ian Kelly
On Wed, Aug 28, 2013 at 5:42 AM, Fabrice POMBET fp2...@gmail.com wrote: On 8/28/2013 4:57 AM, Piotr Dobrogost wrote: 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? the point of str(obj) is to

Re: Rép : Why is str(None) == 'None' and not an empty string?

2013-08-29 Thread fp2161
On Thursday, August 29, 2013 12:55:36 PM UTC+2, Ian wrote: On Wed, Aug 28, 2013 at 5:42 AM, Fabrice POMBET fp2...@gmail.com wrote: On 8/28/2013 4:57 AM, Piotr Dobrogost wrote: Having repr(None) == 'None' is sure the right thing but why does str(None) == 'None'? Wouldn't it be

Re: Why is str(None) == 'None' and not an empty string?

2013-08-29 Thread Tim Delaney
On 29 August 2013 20:43, Ian Kelly ian.g.ke...@gmail.com wrote: On Wed, Aug 28, 2013 at 6:21 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: 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

Re: Why is str(None) == 'None' and not an empty string?

2013-08-29 Thread Steven D'Aprano
On Thu, 29 Aug 2013 04:43:16 -0600, Ian Kelly wrote: I've had many occasions where it would have been convenient for str(None) to return the empty string, e.g. when exporting tabular data that includes null values from a database to a spreadsheet. Generally it's safe to just call str() on

Re: Why is str(None) == 'None' and not an empty string?

2013-08-29 Thread Steven D'Aprano
On Fri, 30 Aug 2013 01:57:45 +, Steven D'Aprano wrote: So while I don't doubt that it wouldn't be occasionally convenient to map None to '' rather than 'None', I think it would be surprising and, indeed, dangerous if it happened by default, since it would encourage people to build up SQL

Why is str(None) == 'None' and not an empty string?

2013-08-28 Thread Piotr Dobrogost
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? Regards Piotr Dobrogost -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is str(None) == 'None' and not an empty string?

2013-08-28 Thread Terry Reedy
On 8/28/2013 4:57 AM, Piotr Dobrogost wrote: 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? No. There is no reason to be different. -- Terry Jan Reedy --

Rép : Why is str(None) == 'None' and not an empty string?

2013-08-28 Thread Fabrice POMBET
On 8/28/2013 4:57 AM, Piotr Dobrogost wrote: 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? the point of str(obj) is to return a string containing the obj (a sequence of characters if it is unbound

Re: Why is str(None) == 'None' and not an empty string?

2013-08-28 Thread Steven D'Aprano
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