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

Aaron DeVore aaron.devore at gmail.com
Thu Oct 13 11:02:45 CEST 2011


On Thu, Oct 13, 2011 at 12:32 AM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> 2. namespaces
>
> I hate using a class definition as a plain namespace, but the
> following is cool (if I'm reading this right):
>
>   :some_func(@.x, @.y)
>   class _:
>       x = 4
>       y = 1
>
> and given a purer namespace (like http://code.activestate.com/recipes/577887):
>
>   :some_func(**@)
>   @as_namespace
>   class _:
>       x = 4
>       y = 1

A clean way to have multiple function could be an issue. Perhaps add a
syntax to refer to either the first function (@) or a named
function(@x)? I can't think of a great syntax to group the function
definitions, though.


> 1. Leave classes out of it, at least for now. We did that with
> decorators, and I think it's a reasonable approach to follow.

-1. This sounds useful for classes. I'm not sure what, but it still
sounds useful.

> 2. The initial version should be an alternative to decorator syntax,
> not an addition to it. That is, you wouldn't be able to mix the first
> incarnation of a block prefix with ordinary decorators.

That would kill off usage of some handy decorators like functools.wraps:

  :some_func(@)
  @wraps(other_func)
  def f(b):
      # function body

-Aaron DeVore



More information about the Python-ideas mailing list