True == 1 weirdness

Grant Edwards invalid at invalid.invalid
Wed Sep 16 13:27:28 EDT 2015


On 2015-09-16, Sven R. Kunze <srkunze at mail.de> wrote:
> On 16.09.2015 18:57, Random832 wrote:
>> I think that chaining should be limited to:
>>
>> A) all operators are "="
>> B) all operators are "is"
>> C) all operators are either >= or >
>> D) all operators are either <= or <
>
> That certainly would be a fine guideline. Only use it with all operators 
> the same.

I find that the only times I use chaining (intentionally), are in
cases C and D.  All other instances of chaining in my code are
invariably typos/bugs.

> Everything else might cause headaches.

I'm not all that sure A and B should be allowed.

> Restricting it language-wise? I don't know. I have to admit I've never 
> seen this in production anyway. Most languages I see people working with 
> don't have this feature at all. So, they don't know it exists in Python.

I use C and D intentionally, and have tripped accidentally over other
cases.

-- 
Grant Edwards               grant.b.edwards        Yow! Hey, waiter!  I want
                                  at               a NEW SHIRT and a PONY TAIL
                              gmail.com            with lemon sauce!



More information about the Python-list mailing list