Explanation of list reference

Rustom Mody rustompmody at gmail.com
Sun Feb 16 11:50:45 EST 2014


On Sunday, February 16, 2014 9:59:53 PM UTC+5:30, Ned Batchelder wrote:
> On 2/16/14 9:00 AM, Rustom Mody wrote:
> > On Saturday, February 15, 2014 7:14:39 PM UTC+5:30, Marko Rauhamaa wrote:
> >> Mark Lawrence:
> >>> I have no interest in understanding object identity, I can write code
> >>> quite happily without it.
> >> Luckily, what we are now debating is mostly terminology and points of
> >> view where the outcomes are unaffected.
> >> However, as an example, it is important to know if you should write:
> >>     if x is not None:
> >>         ...
> >> or if
> >>     if x != None:
> >>         ...
> >> is more robust.
> > Yes This is my main beef:
> > Not that both are possible but that the first is *recommended* and the second not.

> I'm not sure why you don't like the recommendation, or if you just want 
> people to be more explicit about why it is recommended.  My main reason 
> for preferring "x is not None" is that if x's class defines __ne__ 
> incorrectly, "x != None" can come out wrong.  And yes, I have actually 
> debugged problems where that was the root cause.

> If you use "x is not None", nothing about x's class can interfere with 
> the correct operation.

Ok
But for that Ive to use is
And as a teacher Ive to explain is
Might as well use C and get on with pointers

To me 'is' is a can of worms
Mostly I dont need to open that can
In the few instances when I need to open it, I am allowed (I hope!)
to say "Ugh!"




More information about the Python-list mailing list