Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Inline Calculation of Dictionary Values
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Peter Otten, post: 4062061"] Please think of the children ;) The function based approach is the way to go: def f2(): cookie = modify_state() try: return f() finally: restore_state(cookie) This will restore the state even if f() raises an exception. If you want something more fancy you can parameterize f2() by the three functions or look into context managers. Peter [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Inline Calculation of Dictionary Values
Top