[Python-ideas] Before and after the colon in funciton defs.

Nick Coghlan ncoghlan at gmail.com
Sat Sep 17 08:16:19 CEST 2011


On Sat, Sep 17, 2011 at 3:47 PM, Ron Adam <ron3200 at gmail.com> wrote:
> I was thinking it would be good if the parts in front of the colon were
> valid python statements except in the case of the already special
> docstrings and decorators.

You did say that, but advanced no arguments in favour of breaking with
the language aesthetic that way. Indented suites are introduced by a
colon on the preceding header line and you'd need a really compelling
argument to change that. "It might be nice" doesn't cut it.

Specifically targeting existing uses of the default argument hack, on
the other hand, comes with at least 3 already known use cases (i.e.
name lookup micro-optimisation, early binding semantics and shared
state for algorithms). People already tolerate messing with the
function signature to obtain those behaviours, so it's reasonable to
wonder if it is possible to provide a cleaner way to obtain the same
effect. A simple set of definition time name bindings would likely
suffice without greatly increasing the language complexity or the
runtime overhead of function calls.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list