On 09/27/2016 04:01 PM, Peng Yu wrote:
Hi, In many other functional language, one can change the closure of a
function. Is it possible in python?

http://ynniv.com/blog/2007/08/closures-in-python.html


If I understood correctly your link:

(untested)
def func(x):
    return x+func.y

func.y = 10
func(5) => 15
func.y = 100
func(5) => 105

implements a closure of a function.


jm

Note: function are objects, and can have attributes, however I rarely see usage of these, there could be good reasons for that.



--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to