[Python-Dev] statement vs expression [was: (try-except) conditional expression similar to (if-else) conditional (PEP 308)]

Jim Jewett jimjjewett at gmail.com
Mon Aug 10 02:55:12 CEST 2009


> Kristján Valur Jónsson wrote:
>> I've never understood the need to have a distinction betwen statements
>>  and expressions, not when expressions can have side effects.

Alex Martelli responded:
> If you're interested in understanding it better, research
> Query-Command Separation (QCS), e.g. starting at
> http://en.wikipedia.org/wiki/Command-query_separation

Either you missed Kristján's point, or your answer was so
subtle that I missed yours.

QCS makes it easy to determine which pieces of code
(queries) are free of side-effects.  I see value in that
for both debugging and optimization.

What I don't see is how that relates to expressions vs
statements **when expressions can have side effects.**

(Actually, in Python, I would say that statements are far
*more* likely to be free of side-effects, as they are often
there for flow control.)

-jJ


More information about the Python-Dev mailing list