Popular recipes tagged "variable" but not "global"http://code.activestate.com/recipes/tags/variable-global/2010-09-05T17:06:04-07:00ActiveState Code Recipes Keyword Argument Injection with Python Decorators (Python)
2010-09-05T17:06:04-07:00Ahmet Emre Aladağhttp://code.activestate.com/recipes/users/4174877/http://code.activestate.com/recipes/577382-keyword-argument-injection-with-python-decorators/
<p style="color: grey">
Python
recipe 577382
by <a href="/recipes/users/4174877/">Ahmet Emre Aladağ</a>
(<a href="/recipes/tags/class/">class</a>, <a href="/recipes/tags/class_decorator/">class_decorator</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/injection/">injection</a>, <a href="/recipes/tags/variable/">variable</a>).
Revision 2.
</p>
<p>In most of the object oriented codes we write, we need to set class attributes to the given argument values and this is a very line-consuming thing. To get over these redundant lines, I found a solution using decorators. </p>
Adding the directory of the python executable to the system PATH under windows (Python)
2010-05-19T19:01:31-07:00Anthon van der Neuthttp://code.activestate.com/recipes/users/2403822/http://code.activestate.com/recipes/577233-adding-the-directory-of-the-python-executable-to-t/
<p style="color: grey">
Python
recipe 577233
by <a href="/recipes/users/2403822/">Anthon van der Neut</a>
(<a href="/recipes/tags/environment/">environment</a>, <a href="/recipes/tags/executable/">executable</a>, <a href="/recipes/tags/path/">path</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/variable/">variable</a>).
</p>
<p>If you install python under windows and then open a command shell (DOS-prompt, you normally get an error message
if you type "python" at the prompt. This is because the directory of the python executable is not in the PATH environment variable.
If you know where you installed python, you can add this via Control Panel -> System -> Advanced -> Environment Variables but this is not very user friendly way of doing things and error prone.</p>
<p>This program, if run by double clicking the file or by dragging the file to a command shell, will add the directory of the executable associated with the .py extension to the PATH env. var (if it is not already in there). It will notify other programs of this change, but unfortunately <a href="http://command.com" rel="nofollow">command.com</a> is not smart enough to understand that. You have to open a new command shell after running the program in order to be able to run "python" at the dos prompt.</p>
<p>If run with the optional command line parameter 'remove' the directory will be removed from the PATH.</p>