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

H. Krishnan hetchkay at gmail.com
Wed Sep 21 09:37:40 CEST 2011



To me that's like a 'static' declaration in C++, which in Python might
> be something like:
>
> def f(a):
>      static len=len
>      static alist=[]
>      alist.append(a)
>      return len(alist)
>
> What follows 'static' would be an assignment which is executed when the
> function is defined, much like a default argument, and would be shared
> between invocations in the same way.
>
> How about
def f(a) with len as len, [] as alist:
    alist.append(a)
    return len(alist)

Or if "len as len" is redundant:
def f(a) with len, [] as alist:
    alist.append(a)
    return len(alist)

Krishnan 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110921/69a787d7/attachment.html>


More information about the Python-ideas mailing list