PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

Tim Chase python.list at tim.thechases.com
Tue Feb 11 10:26:46 EST 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:

http://www.catster.com/files/600px-cat-hiding-under-rug.jpg

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.

-tkc





More information about the Python-list mailing list