[Tutor] was no subject, getting started
dman
dsh8290@rit.edu
Sat, 2 Mar 2002 11:34:27 -0500
[ I missed the beginning of this -- messages with "(no subject)" as
the subject are automatically dropped on my system ]
On Sat, Mar 02, 2002 at 04:56:09PM +0100, Charlie Clark wrote:
| On 2002-03-02 at 13:10:03, tutor-request@python.org wrote:
| > money = 1000
| > none = 100
| > print money + none
|
| Nobody else mentioned this but "None" is a reserved word in Python: it
It is not a reserved word. It is a built-in name. The difference is
evident in the following lines :
None = "yo"
for = "yo"
The former works and is totally legal. I don't recommend it, however,
since it creates a local variable that "overshadows" the built-in
variable.
The latter doesn't work because "for" is a reserved word (aka keyword).
| stands for an object with no content so it is not the same as "0". Python
| is case sensitive so your variable "none" is different to "None". You can
| overwrite such words in Python without raising an error but this is quite
| likely to cause confusion and thus problems.
|
| The people who write Python are careful not to create too many reserved
| words so that the chances of this happening are rare. Ones to watch out for
| are "list" and "type"
The moral is correct, but the details are not. "list" and "type" are
built-ins, not keywords.
-D
--
Stay away from a foolish man,
for you will not find knowledge on his lips.
Proverbs 14:7