[Python-ideas] Objectively Quantifying Readability
Tim Peters
tim.peters at gmail.com
Tue May 1 15:07:29 EDT 2018
Objectively quantifying is easy. For example,
def objective_readability_score(text):
"Return the readability of `text`, a float in 0.0 .. 1.0"
return 2.0 * text.count(":=") / len(text)
Then
>>> objective_readability_score("if value:")
0.0
>>> objective_readability_score("if value := f():")
0.125
>>> objective_readability_score(":=:=:=")
1.0
QED ;-)
More information about the Python-ideas
mailing list