From: Gregory Ewing on
Steven D'Aprano wrote:
> Generally,
> when testing for None, you actually want None and not some look-alike
> that merely tests equal to None.

That's true, although I can't think of a use case for an object
that compares equal to None but isn't -- except for obfuscated
code competition entries and making obscure points in usenet
discussions. :-)

--
Greg
From: Ben Finney on
Steven D'Aprano <steve(a)REMOVE-THIS-cybersource.com.au> writes:

> On Thu, 05 Aug 2010 12:07:53 -0400, wheres pythonmonks wrote:
>
> > P.S. Sorry for the top-post -- is there a way to not do top posts
> > from gmail? I haven't used usenet since tin.
>
> Er, surely you can just move the cursor before you start typing???

I like to think that the cursor is placed at the top by default so that
<URL:http://en.wikipedia.org/wiki/Posting_style#Interleaved_style> is
easy: just travel down through the quoted material, removing it if not
relevant and inserting one's responses where needed.

--
\ “Two hands working can do more than a thousand clasped in |
`\ prayer.” —Anonymous |
_o__) |
Ben Finney
From: Stefan Schwarzer on
Hi Steven,

On 2010-08-07 00:28, Steven D'Aprano wrote:
> On Fri, 06 Aug 2010 15:37:04 +0200, Stefan Schwarzer wrote:
>>> Plus, I believe the
>>> "==" operator will check if the variables point to the same object.
>>
>> No, that's what `is` is for.
>
> Actually, yes, equality is implemented with a short-cut that checks for
> identity first. That makes something like:
> [...]

Oops, I didn't realize that the OP had mentioned the
identity check as an optimization in case the objects are
the same. I thought he was confusing the operator with `is`.

> s = "abc"*1000*1000*10
> s == s
>
> nice and quick, as Python can immediately recognise that a string is
> always equal to itself without having to walk the entire string comparing
> each character with itself.

Yes, that definitely makes sense. I guess I would have
implemented it this way as well. :)

Stefan
From: Gabriel Genellina on
En Sat, 07 Aug 2010 04:04:06 -0300, Stefan Schwarzer
<sschwarzer(a)sschwarzer.net> escribi�:
> On 2010-08-07 00:28, Steven D'Aprano wrote:

>> Actually, yes, equality is implemented with a short-cut
that checks for
>> identity first. That makes something like:
>> [...]
>
> Oops, I didn't realize that the OP had mentioned the
> identity check as an optimization in case the objects are
> the same. I thought he was confusing the operator with `is`.
>
>> s = "abc"*1000*1000*10
>> s == s
>>
>> nice and quick, as Python can immediately recognise that a string is
>> always equal to itself without having to walk the entire string
>> comparing
>> each character with itself.
>
> Yes, that definitely makes sense. I guess I would have
> implemented it this way as well. :)

For strings and other internal types this optimization certainly makes
sense. For user-defined types it gets in the way and prevents defining an
object such x==x is False (like NANs).

--
Gabriel Genellina

From: Steven D'Aprano on
On Sat, 07 Aug 2010 14:28:19 +1000, Ben Finney wrote:

> Steven D'Aprano <steve(a)REMOVE-THIS-cybersource.com.au> writes:
>
>> On Thu, 05 Aug 2010 12:07:53 -0400, wheres pythonmonks wrote:
>>
>> > P.S. Sorry for the top-post -- is there a way to not do top posts
>> > from gmail? I haven't used usenet since tin.
>>
>> Er, surely you can just move the cursor before you start typing???
>
> I like to think that the cursor is placed at the top by default so that
> <URL:http://en.wikipedia.org/wiki/Posting_style#Interleaved_style> is
> easy: just travel down through the quoted material, removing it if not
> relevant and inserting one's responses where needed.

Yes, but apparently millions of Internet users have keyboards where
neither the cursor keys nor backspace/delete works. Being unable to
interleave their reply with the quoted text, they end up quoting the
entire week-long thread at the bottom of every email they send.

I blame Manservant Neville.


--
Steven