> cnt = 1
> def foo():
>       global cnt
>       cnt += 1
>       return cnt
>
> def bar(x=foo()):
>       print x
>
> bar() # 2
> bar() # 2
> bar() # 2

Looks to me like you want to use the following programming pattern to
get dynamic default arguments:

cnt = 1
def foo():
        global cnt
        cnt += 1
        return cnt

def bar(x=None):
        if x is None:
                x = foo()
        print x
 
bar()   # 2
bar()   # 3
bar()   # 4

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

Reply via email to