Most viewed recipes tagged "expanding"http://code.activestate.com/recipes/tags/expanding/views/2010-10-25T01:59:49-07:00ActiveState Code Recipesdealing with directory paths with ~ (Python) 2010-06-16T23:17:20-07:00roopeshvhttp://code.activestate.com/recipes/users/4174204/http://code.activestate.com/recipes/577270-dealing-with-directory-paths-with/ <p style="color: grey"> Python recipe 577270 by <a href="/recipes/users/4174204/">roopeshv</a> (<a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/expanding/">expanding</a>, <a href="/recipes/tags/paths/">paths</a>). Revision 2. </p> <p>Dealing with directory paths which start with <code>~</code> which are passed as paramaters, to <code>os</code> module functions.</p> <p>Here is what I think python doesn't do for me:</p> <pre class="prettyprint"><code>&gt;&gt;&gt; import os # suppose my home = curdir = /home/rv &gt;&gt;&gt; os.path.abspath('.') '/home/rv' </code></pre> <p>Now if I want to go to folder <code>/home/rv/test</code> if there is no folder by name /home/rv/~/test/</p> <pre class="prettyprint"><code># This is what happens by default. &gt;&gt;&gt; os.path.abspath('~/test') '/home/rv/~/test' &gt;&gt;&gt; os.chdir('/home/rv/some/dir') # doesn't matter if the resulting path exists or not. &gt;&gt;&gt; os.path.abspath('~/test') 'home/rv/some/dir/~/test' </code></pre> <p>This would be more sensible I guess:</p> <pre class="prettyprint"><code># if /home/rv/~/test doesn't exist &gt;&gt;&gt; os.path.abspath('~/test') '/home/rv/test' </code></pre> Simple command submitter for Win32 (Python) 2010-10-25T01:59:49-07:00Phil Risthttp://code.activestate.com/recipes/users/4171119/http://code.activestate.com/recipes/577439-simple-command-submitter-for-win32/ <p style="color: grey"> Python recipe 577439 by <a href="/recipes/users/4171119/">Phil Rist</a> (<a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/expanding/">expanding</a>, <a href="/recipes/tags/win32/">win32</a>). </p> <p>This program is a simple Win32 command submitter. It uses a set of macros similar to those used by the QEditor program, strings such as '{b}'. The macros are replaced with text from a specified file path. Options to change the working directory and selected environment variables are provided. Two examples are provided in the code. <br /> The program does not collect output or provide input. It does one call to the expand routine. It can not recognize parameters containing white space. Do2 which follows does. Module is used by Do2 and ButtonBarV1Ex which follow.</p>