Python Worst Practices

Tim Chase python.list at tim.thechases.com
Fri Feb 27 22:50:35 EST 2015


On 2015-02-28 12:09, Steven D'Aprano wrote:
> > * Make your language have a lot of keywords. Enough to make
> > memorizing them ALL unlikely, requiring constant visits to your
> > documentation   
> 
> Is 33 a lot?
> 
> py> import keyword
> py> keyword.kwlist  
> ['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 
> 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally',
> 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda',
> 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while',
> 'with', 'yield']

A quick google-and-tally for languages and their corresponding
number of keywords:

C: 33
C#: 77
C++: 86
Java: 50
Lua: 21
PHP: 67
Pascal: 54
Perl: 40
Pike: 37 (Just for you, ChrisA)
Python: 31 (2.x) or 33 (3.x)
Ruby: 40

So I can't say that Python's all that bad in comparison to most other
mainstream languages, with only the austere Lua beating out Python.

-tkc





More information about the Python-list mailing list