Python Forum
i wish there was - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: i wish there was (/thread-11499.html)



i wish there was - Skaperen - Jul-12-2018

i wish there was a way to have a function be able to do some big complex calculation to create a big data reference table that is exactly the same each time it is called and save it between calls to avoid repeating all that work each time it is called. i know i could save it in global space, but i'd have to code the function as a module and put some name in the caller's global space. it would have been nice for functions to each have their own way to save data between calls without polluting the caller's global namespace. i suppose i can make it be a class to do it. that's how pike does it. i better not mention that language with a one-letter name.


RE: i wish there was - ichabod801 - Jul-12-2018

You could also do a closure.