On Mon, Jan 30, 2017 at 4:03 PM, Irv Kalb <i...@furrypants.com> wrote:
> It seems very odd that Python allows you to override the values of True and 
> False.  In the code, True and False were clearly recognized as keywords as 
> they were colored purple.  But there was no error message.
>
> You cannot assign new values to other keywords.  Simple tests of things like:
>
> for = 5
>
> while = 2
>
> not = 3
>
> As expected, all result in SyntaxError: invalid syntax.  Why would Python 
> allow you to override the values of True and False?  I wonder if this is some 
> sort of historical thing as these are the only keywords besides None that are 
> uppercased.  This line:
>
> None = 5
>
> Even gives a special SyntaxError: cannot assign to None

There are slightly different things going on here. Trying to assign to
a piece of syntax like "while" makes absolutely no sense, but trying
to assign to "None" is structurally sane, yet disallowed. IIRC there's
only one non-assignable name in Python 2 (None), but as mentioned,
Python 3 adds True and False to that. (Interestingly, Ellipsis is not
included in that.)

> I teach intro to programming using Python.

May I please request that you consider teaching Python 3? Python 2
isn't going anywhere (for better or for worse), and Py3 is a superior
language in many ways, not least of which is that it keeps text and
bytes separate, giving text the full power that it should have. For a
beginning programmer, this is very helpful; there's nothing to
un-learn when going international. (There will be new nuances to be
learned, such as RTL text, but nothing to unlearn.) Python 3 also
fixes a number of other problems that Python 2 inherited from C,
making it altogether a better language for teaching with.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to