
Screwtape at
Python 3 has the 'nonlocal' keyword that does exactly what you want (if you inserted "nonlocal x" as the first line of _func(), it would do the right thing)... but, well, you don't get it unless you switch to Python 3.
Claes Wallin (韋嘉誠), Christopher Allan Webber, lnxwalt@microca.st likes this.