Overriding True and False ?

jladasky at itu.edu jladasky at itu.edu
Tue Jan 31 16:34:32 EST 2017


On Sunday, January 29, 2017 at 11:29:29 PM UTC-8, Irv Kalb wrote:

> It seems very odd that Python allows you to override the values of 
> True and False.

Hi Irv,

Let me join the chorus of people who are encouraging you to switch to Python3, which corrects this problem.  Overriding builtins has been judged harmful, and now it is a lot harder to do.

There are sometimes good reasons for shadowing builtins, but more than a few newcomers to Python (once upon a time, myself included) wrote buggy code by accident because of this surprising flexibility.

That being said, I can't resist re-posting a story from 14 years ago:

https://groups.google.com/forum/#!original/comp.lang.python/xEtUYsxLnFE/6yYgvhvkggMJ

==============

From: lad... at my-deja.com (John Ladasky)
Newsgroups: comp.lang.python
Subject: Re: Python 2.3 True = False
Date: 24 Mar 2003 12:29:04 -0800

an... at calbay.com (Anand) wrote in message news:<c6303995.0303... at posting.google.com>...
> >>> True = False
> >>> True
>  False

Shhh!  Anand!  You're not supposed to show anyone that!  Now every
politician on Earth will want to program in Python!

==============


More information about the Python-list mailing list