Why True/False is capitalized in Python?

PythonCamelcasing

Python Problem Overview


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

Python Solutions


Solution 1 - Python

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.

Solution 2 - Python

All of python's built-in constants are capitalized or [upper] CamelCase:

Solution 3 - Python

Here's a possible explaination:

> > I see that naming conventions are such that classes usually get named > > CamelCase. So why are the built-in types named all lowercase (like > > list, dict, set, bool, etc.)? > > Because most of them originally were > types and factory functions, not
> classes - and a naming convention is > not a strong reason to make backwards > incompatible changes. A different > example: the new builtin type set is > based on (altough not exactly equal > to) the Set class from the sets module

Solution 4 - Python

In python only the 3 keywords True ,False and None are started with capital letters. I think This is to differentiate these 3 keywords from others. These 3 keywords can be used as literals or values where as other keywords not. For example

a=True is correct but a=for is wrong

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJoan VengeView Question on Stackoverflow
Solution 1 - PythonJames SulakView Answer on Stackoverflow
Solution 2 - PythonAndrew JaffeView Answer on Stackoverflow
Solution 3 - PythonStephenView Answer on Stackoverflow
Solution 4 - PythonRanjan DasView Answer on Stackoverflow