python 3's adoption

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Thu Jan 28 02:09:58 CET 2010


On Wed, 27 Jan 2010 00:36:52 -0800, Paul Rubin wrote:

> Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> writes:
>> Without becoming a purely functional language, you won't get rid of all
>> statements.
> 
> Why not?  GCC lets you use any statement in an expression:

I stand corrected. Whether it is a good idea or not is another story.



>> for, while, if, try, break, yield, return are all used for flow
>> control, and should remain as statements.
> 
> What about assert, import, and pass?

Both assert and pass are special and need to be treated specially by the 
compiler. Arguably we could replace pass with None, but pass makes the 
intent more obvious. 

Although assert could be a function, it is treated specially by the 
compiler and so making it a statement emphases that it is special.

The regular form of import could easily be a function returning the 
module object. After all, that's exactly what __import__ is! But using 
__import__ for anything but the simplest cases is quite awkward, hence we 
have syntactic sugar in the form of the import statement.

You also missed del as another statement-based command.

All the current statements have good strong reasons for being statements. 
print on the other hand lacks a strong reason for being a statement, and 
the only good argument against changing is to avoid an incompatible 
change. But since it is not a gratuitous incompatible change, the long 
term benefit out-weighs the short-term pain, in my opinion.


-- 
Steven



More information about the Python-list mailing list