PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)
python.list at tim.thechases.com
Tue Feb 11 16:26:46 CET 2014
On 2014-02-11 06:30, Steven D'Aprano wrote:
> You need to understand the difference between syntax and semantics.
> This is invalid English syntax:
> "Cat mat on sat the."
> This is valid syntax, but semantically wrong:
> "The mat sat on the cat."
> This is both syntactically and semantically correct:
> "The cat sat on the mat."
And there are times you *do* want to do unconventional things with
the language, and Python allows that:
because in that particular use case, it *is* semantically correct.
> With Python's correct design, we have:
> spam # always, without exception, refers to the object
> spam() # always, without exception, calls the object
> With your suggested design, we would have:
> spam # sometimes refers to the object, sometimes calls the object
> spam() # always calls the object
> Ruby makes this mistake, and is a lessor language for it.
One of the (many) reasons Ruby drives me nuts.
More information about the Python-list