<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Run Only Selected Text with Python?]]></title><description><![CDATA[<p dir="auto">Is there a way to run only selected text with Python?<br />
NPPExec plugin seems to let you run only an entire saved script.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/25922/run-only-selected-text-with-python</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 20:09:10 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/25922.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Jul 2024 15:25:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Run Only Selected Text with Python? on Fri, 05 Jul 2024 20:13:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chigkim" aria-label="Profile: chigkim">@<bdi>chigkim</bdi></a> ,</p>
<p dir="auto">Then you need to learn how to run <a href="https://docs.python.org/3/using/cmdline.html#cmdoption-c" rel="nofollow ugc">python code from a command-line argument instead of from a script</a>.  That’s a python question, not a Notepad++ question.</p>
<p dir="auto">The Notepad++ specific part of your question is how to access the selection in an NppExec script (or Run command), and you now have that information.</p>
<p dir="auto">Though I’ll thow you a fish: if you can figure out how to use Notepad++'s default plugins, then <code>cHl0aG9uIC1jICJwcmludCgkKENVUlJFTlRfV09SRCkpIg</code> can be easily decoded to hand you the answer.  But any further questions about how to use python.exe are off topic here.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/95672</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/95672</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 05 Jul 2024 20:13:15 GMT</pubDate></item><item><title><![CDATA[Reply to Run Only Selected Text with Python? on Fri, 05 Jul 2024 19:27:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> Thanks for the response.<br />
If I select 3+3 and run <code>python "$(CURRENT_WORD)"</code> I get:<br />
python.exe: can’t open file ‘…Notepad++64\3’: [Errno 2] No such file or directory<br />
I guess it’s trying to run the file 3+3, not actually run the text 3+3 in python.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/95670</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/95670</guid><dc:creator><![CDATA[chigkim]]></dc:creator><pubDate>Fri, 05 Jul 2024 19:27:40 GMT</pubDate></item><item><title><![CDATA[Reply to Run Only Selected Text with Python? on Thu, 04 Jul 2024 15:30:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chigkim" aria-label="Profile: chigkim">@<bdi>chigkim</bdi></a> ,</p>
<p dir="auto"><code>$(CURRENT_WORD)</code> works in NppExec (or the <strong>Run</strong> menu’s <strong>Run…</strong> command) to give the contents of the active selection.  This is documented in the <strong>Plugins &gt; NppExec &gt; Docs &gt; <code>NppExec_HelpAll.txt</code></strong>  (and <a href="https://npp-user-manual.org/docs/config-files/#userdefinedcommands" rel="nofollow ugc">NPP User Manual &gt; Config Files &gt; User Defined Commands</a>)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/95662</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/95662</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 04 Jul 2024 15:30:22 GMT</pubDate></item></channel></rss>