[Python-ideas] Statement local functions and classes (aka PEP 3150 is dead, say 'Hi!' to PEP 403)

David Townshend aquavitae69 at gmail.com
Wed Oct 19 08:44:40 CEST 2011


Regarding out of order execution: how is pep 3150 any worse than "x = y if z
else w"? Apart from the fact than this sort of statement is usually quite
short, the middle part still gets executed before the start.

Either way, out of order execution hurts readability. There's a reason that
> even mathematicians usually define terms before using them.


On the other hand, I have read countless scientific papers which define
functions along the lines of "this phenomenon can be represented by the
equation x=2sin(yz), where x is the natural frequency, y is the height of
the giraffe and z is the number of penguins".  Just saying...

Changing the subject slightly, I haven't studied the details of the proposed
grammar, but if given can be used in simple statements, this implies that
the following would be possible:

def function_with_annotations() -> x given:
    x = 4:
    function_body()

I assume I'm not alone in thinking that this is a really bad idea (if the
current grammar does actually allow it). However, "given" in def statements
would be a great way of dealing with the recently discussed question of how
to define function variables at definition time:

def function() given (len=len):
    ...


David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20111019/f8fc616a/attachment.html>


More information about the Python-ideas mailing list