Top-rated recipes tagged "dynamic_method"http://code.activestate.com/recipes/tags/dynamic_method/top/2016-06-12T15:27:59-07:00ActiveState Code RecipesPython AsciiColor and video attributes (Python) 2014-07-24T04:25:53-07:00Mike 'Fuzzy' Partinhttp://code.activestate.com/recipes/users/4179778/http://code.activestate.com/recipes/578908-python-asciicolor-and-video-attributes/ <p style="color: grey"> Python recipe 578908 by <a href="/recipes/users/4179778/">Mike 'Fuzzy' Partin</a> (<a href="/recipes/tags/ascii/">ascii</a>, <a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/dynamic_method/">dynamic_method</a>, <a href="/recipes/tags/metaprogramming/">metaprogramming</a>, <a href="/recipes/tags/python/">python</a>). Revision 5. </p> <p>This is a subclass of a standard str object that adds methods for applying color, and video attributes to text.</p> Drive which Python functions are executed via a text file (Python) 2016-06-12T15:27:59-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580681-drive-which-python-functions-are-executed-via-a-te/ <p style="color: grey"> Python recipe 580681 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/adapter/">adapter</a>, <a href="/recipes/tags/configuration/">configuration</a>, <a href="/recipes/tags/dynamic/">dynamic</a>, <a href="/recipes/tags/dynamic_method/">dynamic_method</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/runtime/">runtime</a>). </p> <p>This recipe shows a simple way of externally controlling which Python functions (out out of some) in your program get executed. The control is done at run time, so no code changes to the program are needed, for different choices. The control is done using a text file.</p> Simple shelve with Linux file locking (Python) 2008-12-21T05:50:07-08:00Michael Ihdehttp://code.activestate.com/recipes/users/4168518/http://code.activestate.com/recipes/576591-simple-shelve-with-linux-file-locking/ <p style="color: grey"> Python recipe 576591 by <a href="/recipes/users/4168518/">Michael Ihde</a> (<a href="/recipes/tags/dynamic_method/">dynamic_method</a>, <a href="/recipes/tags/locking/">locking</a>, <a href="/recipes/tags/shelve/">shelve</a>). </p> <p>The shelve module is a easy way to add persistence to your application via a DBM database. However, if you have multiple reader/writer combination you need to lock the file to prevent corruption. The shelve module itself does not provide locking because it is platform specific. If you only need Linux, this simple module provide an easy way to support locking using dynamically added methods.</p>