<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Running Python Code in Windows Batch File Trick</title>
	<atom:link href="http://www.halotis.com/2009/08/21/running-python-code-in-windows-batch-file-trick/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.halotis.com/2009/08/21/running-python-code-in-windows-batch-file-trick/</link>
	<description>Entrepreneurship in the 21st Centruy</description>
	<lastBuildDate>Sat, 21 Jan 2012 09:19:41 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Youpsla</title>
		<link>http://www.halotis.com/2009/08/21/running-python-code-in-windows-batch-file-trick/comment-page-1/#comment-18248</link>
		<dc:creator>Youpsla</dc:creator>
		<pubDate>Sat, 03 Dec 2011 02:19:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.halotis.com/?p=689#comment-18248</guid>
		<description>It&#039;s not the same using the trick and addig.py in PATHEXT.

For example, I use pycron to launch a python script wich import modules.

Without the trick, I&#039;ve an import module error at the first import.

I don&#039;t know internallt how it works but it works !!

Thanks for the trick</description>
		<content:encoded><![CDATA[<p>It&#8217;s not the same using the trick and addig.py in PATHEXT.</p>
<p>For example, I use pycron to launch a python script wich import modules.</p>
<p>Without the trick, I&#8217;ve an import module error at the first import.</p>
<p>I don&#8217;t know internallt how it works but it works !!</p>
<p>Thanks for the trick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Youpsla</title>
		<link>http://www.halotis.com/2009/08/21/running-python-code-in-windows-batch-file-trick/comment-page-1/#comment-18247</link>
		<dc:creator>Youpsla</dc:creator>
		<pubDate>Sat, 03 Dec 2011 02:19:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.halotis.com/?p=689#comment-18247</guid>
		<description>It&#039;s not the same using the trick and addig.py in PATHEXT.

For example, I use pycron to launch a python script wich import modules.

Without the trick, I&#039;ve an import module error at the first import.

I don&#039;t know internallt how it works but it works !!

Thanks for the trick</description>
		<content:encoded><![CDATA[<p>It&#8217;s not the same using the trick and addig.py in PATHEXT.</p>
<p>For example, I use pycron to launch a python script wich import modules.</p>
<p>Without the trick, I&#8217;ve an import module error at the first import.</p>
<p>I don&#8217;t know internallt how it works but it works !!</p>
<p>Thanks for the trick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Youpsla</title>
		<link>http://www.halotis.com/2009/08/21/running-python-code-in-windows-batch-file-trick/comment-page-1/#comment-18246</link>
		<dc:creator>Youpsla</dc:creator>
		<pubDate>Sat, 03 Dec 2011 02:18:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.halotis.com/?p=689#comment-18246</guid>
		<description>It&#039;s not the same using the trick and addig.py in PATHEXT.

For example, I use pycron to launch a python script wich import modules.

Without the trick, I&#039;ve an import module error at the first import.

I don&#039;t know internallt how it works but it works !!

Thanks for the trick</description>
		<content:encoded><![CDATA[<p>It&#8217;s not the same using the trick and addig.py in PATHEXT.</p>
<p>For example, I use pycron to launch a python script wich import modules.</p>
<p>Without the trick, I&#8217;ve an import module error at the first import.</p>
<p>I don&#8217;t know internallt how it works but it works !!</p>
<p>Thanks for the trick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Running Python Code in Windows Batch File Trick &#124; Ben&#039;s Computer Graphics Blog</title>
		<link>http://www.halotis.com/2009/08/21/running-python-code-in-windows-batch-file-trick/comment-page-1/#comment-17763</link>
		<dc:creator>Running Python Code in Windows Batch File Trick &#124; Ben&#039;s Computer Graphics Blog</dc:creator>
		<pubDate>Mon, 15 Aug 2011 09:19:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.halotis.com/?p=689#comment-17763</guid>
		<description>[...] Running Python Code in Windows Batch File Trick [...]</description>
		<content:encoded><![CDATA[<p>[...] Running Python Code in Windows Batch File Trick [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Warren</title>
		<link>http://www.halotis.com/2009/08/21/running-python-code-in-windows-batch-file-trick/comment-page-1/#comment-16038</link>
		<dc:creator>Matt Warren</dc:creator>
		<pubDate>Tue, 25 Aug 2009 16:44:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.halotis.com/?p=689#comment-16038</guid>
		<description>quite right.  you can just set Windows to associate the .py file with python.  what this .bat file trick accomplishes is to make it familiar to users that are not used to running .py files.  Now they get a .bat file which they know they can click to run a program.  It&#039;s just one less thing that you have to explain to users of your scripts.

There are lots of people in my office that if I sent them a python script I would get a &quot;What do I do with this?&quot; type response.  But they would know what to do with a .bat file.</description>
		<content:encoded><![CDATA[<p>quite right.  you can just set Windows to associate the .py file with python.  what this .bat file trick accomplishes is to make it familiar to users that are not used to running .py files.  Now they get a .bat file which they know they can click to run a program.  It&#8217;s just one less thing that you have to explain to users of your scripts.</p>
<p>There are lots of people in my office that if I sent them a python script I would get a &#8220;What do I do with this?&#8221; type response.  But they would know what to do with a .bat file.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg</title>
		<link>http://www.halotis.com/2009/08/21/running-python-code-in-windows-batch-file-trick/comment-page-1/#comment-15987</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Sun, 23 Aug 2009 04:37:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.halotis.com/?p=689#comment-15987</guid>
		<description>Don&#039;t get me wrong - much kudos to you for this cleverness.  I just have zero use for this in a production environment.</description>
		<content:encoded><![CDATA[<p>Don&#8217;t get me wrong &#8211; much kudos to you for this cleverness.  I just have zero use for this in a production environment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg</title>
		<link>http://www.halotis.com/2009/08/21/running-python-code-in-windows-batch-file-trick/comment-page-1/#comment-15986</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Sun, 23 Aug 2009 04:32:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.halotis.com/?p=689#comment-15986</guid>
		<description>How is this useful? On my machines, I simply associate .py extensions to Python. Done. Runs when I doubleclick it now.
On others&#039; machines that don&#039;t have Python, I compile my script using Py2Exe. Runs when they doubleclick it now.</description>
		<content:encoded><![CDATA[<p>How is this useful? On my machines, I simply associate .py extensions to Python. Done. Runs when I doubleclick it now.<br />
On others&#8217; machines that don&#8217;t have Python, I compile my script using Py2Exe. Runs when they doubleclick it now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://www.halotis.com/2009/08/21/running-python-code-in-windows-batch-file-trick/comment-page-1/#comment-15981</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Sat, 22 Aug 2009 14:40:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.halotis.com/?p=689#comment-15981</guid>
		<description>Why not just register .py files as runnable?

You&#039;d have to do this for every python file you want to launch, it prevents you from using the same file for both script and module, and it seems needlessly complex when you can accomplish the same goal for every python file simply by registering the .py extension (already done by the installer) and extending the PATHEXT environment variable:

&lt;pre&gt;
c:\&gt; echo import sys; print &#039; &#039;.join(sys.argv[1:]) &gt;test.py
c:\&gt; SET PATHEXT=%PATHEXT%;.py
c:\&gt; test hello world
hello world
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Why not just register .py files as runnable?</p>
<p>You&#8217;d have to do this for every python file you want to launch, it prevents you from using the same file for both script and module, and it seems needlessly complex when you can accomplish the same goal for every python file simply by registering the .py extension (already done by the installer) and extending the PATHEXT environment variable:</p>
<pre>
c:\&gt; echo import sys; print ' '.join(sys.argv[1:]) &gt;test.py
c:\&gt; SET PATHEXT=%PATHEXT%;.py
c:\&gt; test hello world
hello world
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Warren</title>
		<link>http://www.halotis.com/2009/08/21/running-python-code-in-windows-batch-file-trick/comment-page-1/#comment-15980</link>
		<dc:creator>Matt Warren</dc:creator>
		<pubDate>Sat, 22 Aug 2009 13:55:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.halotis.com/?p=689#comment-15980</guid>
		<description>I updated the batch file line to pass through the command line arguments.

Example Usage:
&lt;pre lang=&quot;bash&quot;&gt;$ echo.bat test
test
&lt;/pre&gt;

Here&#039;s what echo.bat looks like:
&lt;pre lang=&quot;python&quot;&gt;@setlocal enabledelayedexpansion &amp;&amp; python -x &quot;%~f0&quot; %* &amp; exit /b !ERRORLEVEL!
#start python code here
import sys
print sys.argv[1]

&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I updated the batch file line to pass through the command line arguments.</p>
<p>Example Usage:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ echo.bat <span style="color: #7a0874; font-weight: bold;">test</span>
<span style="color: #7a0874; font-weight: bold;">test</span></pre></div></div>

<p>Here&#8217;s what echo.bat looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">@setlocal enabledelayedexpansion <span style="color: #66cc66;">&amp;</span>amp<span style="color: #66cc66;">;&amp;</span>amp<span style="color: #66cc66;">;</span> python -x <span style="color: #483d8b;">&quot;%~f0&quot;</span> <span style="color: #66cc66;">%*</span> <span style="color: #66cc66;">&amp;</span>amp<span style="color: #66cc66;">;</span> exit /b <span style="color: #66cc66;">!</span>ERRORLEVEL<span style="color: #66cc66;">!</span>
<span style="color: #808080; font-style: italic;">#start python code here</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://www.halotis.com/2009/08/21/running-python-code-in-windows-batch-file-trick/comment-page-1/#comment-15975</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Sat, 22 Aug 2009 08:13:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.halotis.com/?p=689#comment-15975</guid>
		<description>Nice trick. How would you recommend passing in invocation arguments from the command line? I&#039;d like to be able to use sys.argv from within my .bat embedded python program.

thanks</description>
		<content:encoded><![CDATA[<p>Nice trick. How would you recommend passing in invocation arguments from the command line? I&#8217;d like to be able to use sys.argv from within my .bat embedded python program.</p>
<p>thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>

