Python variable scope is type specific? -


from functools import wraps def mywrapper(func):     variable1 = {}     variable2 = 0     @wraps(func)     def newfunc(*args):         if args in variable1:             return variable1[args]         else:             variable1[args] = func(*args)             variable2 = 1             return variable1[args]     return newfunc 

if run code, got error message "local variable variable2 not assigned". if change dictionary, worked fine variable1. confuses me on python variable scopes----does rely on type? using 2.7.6.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -