Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why True/False is capitalized in Python?

All members are camel case, right? Why True/False but not true/false, which is more relaxed?

like image 223
Joan Venge Avatar asked Feb 06 '09 18:02

Joan Venge


People also ask

Does true need to be capitalized in Python?

In Python boolean builtins are capitalized, so True and False. You do not need to explicitly define the data type to boolean. You don't need to say “I want to use a boolean” as you would need in C or Java. Instead Python knows the variable is a boolean based on the value you assign.

Is True False in Python case sensitive?

They are True and False . Capitalization is important, since true and false are not boolean values (remember Python is case sensitive).

Why does Python use capitalization?

In Python, the capitalize() method returns a copy of the original string and converts the first character of the string to a capital (uppercase) letter while making all other characters in the string lowercase letters.


1 Answers

From Pep 285:

Should the constants be called 'True' and 'False' (similar to None) or 'true' and 'false' (as in C++, Java and C99)?

=> True and False.

Most reviewers agree that consistency within Python is more important than consistency with other languages.

This, as Andrew points out, is probably because all (most)? built-in constants are capitalized.

like image 114
James Sulak Avatar answered Oct 16 '22 20:10

James Sulak