Im very confused why the first 3 arnt all correct. As isn't true a keyword, it of course is a Boolean literal and is interchangeable with 1?
Asked
Active
Viewed 395 times
0
-
2it's a literal not a keyword – sawreals Dec 17 '16 at 00:30
-
What makes something a keyword? Believe i read in 3.0 was made into one, so i assume was due to 2.7. – Chrismon Chin Dec 17 '16 at 00:33
-
2Because they are actual values (1 and 0). Keywords are not. – sawreals Dec 17 '16 at 00:34
-
oh okay, and since can be changed as well. thanks! – Chrismon Chin Dec 17 '16 at 00:36
-
If this is Python 2.7, none of those are correct. It is not a keyword or a literal, and it is not the same as either 0 or 1. In Python 3, the first two are correct. – user2357112 Dec 17 '16 at 01:03
1 Answers
2
True
and False
are not keywords, they are boolean values because they are associated with 1 and 0 respectively. For a complete list of keywords see Is it possible to get a list of keywords in Python?
-
They're not literals either. You can assign `True = 12`, or even `import __builtin__; __builtin__.True = 12`, and change what `True` evaluates to, whereas you couldn't do that with a literal. – user2357112 Dec 17 '16 at 01:09
-
@user2357112 those updates you are referring to came about in Python 3.x.x I believe. In which case they are keywords, but the original question pertained to python 2.7. – sawreals Dec 17 '16 at 01:14
-
I'm saying that in 2.7, they are neither literals nor keywords. The fact that they're not one doesn't make them the other. – user2357112 Dec 17 '16 at 01:15