<?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[Convenience technique when organizing PythonScripts into folders]]></title><description><![CDATA[<p dir="auto">So being someone that has a lot of Notepad++ Pythonscripts…I need to apply some organizational techniques to keep them, well, organized.  What this means basically is that I like to create folders for them, based upon what they do.</p>
<p dir="auto">I’ve probably taken this to a bit of an extreme(!), but here’s what my <code>Plugins</code> &gt; <code>PythonScript</code> &gt; <code>Scripts</code> menu looks like:</p>
<p dir="auto"><img src="/assets/uploads/files/1640187254975-f5befd38-ac0a-4994-8f0e-55a6d9b2f6d2-image.png" alt="f5befd38-ac0a-4994-8f0e-55a6d9b2f6d2-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I’ve highlighted in yellow the entries that PythonScript has put there by default; the rest are mine and as you can see, a lot of new folders I’ve created here…(you can tell they are folders by the <code>&gt;</code> off to the right).</p>
<p dir="auto">I’ve noticed that if I want to use a script from one of these folders in a script that lives in another folder, by default Notepad++ won’t be able to find it, example:</p>
<p dir="auto"><code>import NotepadGetStatusBar</code> in one script can result in this error at runtime (this is a real-world example from the script I show <a href="https://community.notepad-plus-plus.org/topic/22298/notepad-encoding-auto-detect-potential-problems">HERE</a> ):</p>
<p dir="auto"><img src="/assets/uploads/files/1640187267764-6aec9efd-a554-48f4-b2d1-dedfb487efd9-image.png" alt="6aec9efd-a554-48f4-b2d1-dedfb487efd9-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Now sure, there are ways to avoid this problem by including path information on the import, but, ok, that’s annoying because I have to look up that path, and then what if I move some scripts around later based upon, I don’t know, maybe a better way of categorizing them?</p>
<p dir="auto">What I’ve done to avoid this is to add a bit of code to my <code>startup.py</code> so that one script can “find” another, without the need for any additional specification.</p>
<p dir="auto">The code looks like this:</p>
<pre><code class="language-z">import os

# add scripts folder tree to the sys.path list
#  (makes it easy to call a script anywhere in the tree by using only the script's base name)
for (root, dirs, files) in os.walk(notepad.getPluginConfigDir() + r'\PythonScript\scripts', topdown=False):
    if root not in sys.path:
        sys.path.append(root)
</code></pre>
<p dir="auto">I’m showing this in the event that it helps someone else streamline their work and organize their scripts better, with minimal pain in the event they call one script from another.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/22299/convenience-technique-when-organizing-pythonscripts-into-folders</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 01:25:07 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/22299.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 22 Dec 2021 15:37:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Convenience technique when organizing PythonScripts into folders on Wed, 05 Jan 2022 15:29:16 GMT]]></title><description><![CDATA[<p dir="auto">I used to have all of my scripts in a private repo at some svn-based competitor to github that allowed free private repos.  I would just check out that repo as my user scripts folder on any machine I’m working on, and automatically get all my scripts wherever I go.</p>
<p dir="auto">As I started sharing more of my scripts, I played a bit with gists, but didn’t like that i had two copies of some scripts – one in the private repo and one in the gist.</p>
<p dir="auto">I realized that I didn’t have <em>any</em> proprietary/private scripts (and if I did, I could put them in my system scripts folder instead), so I moved the repo to my github, so I can share any of them.</p>
<p dir="auto">So it’s not Alan’s collection, but my collection is at <a href="https://github.com/pryrt/nppStuff/tree/main/pythonScripts" rel="nofollow ugc">https://github.com/pryrt/nppStuff/tree/main/pythonScripts</a> … and the nppCommunity subdirectory is the ones I’ve developed for or snagged from this forum, mostly organized by topic-ID.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72677</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72677</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 05 Jan 2022 15:29:16 GMT</pubDate></item><item><title><![CDATA[Reply to Convenience technique when organizing PythonScripts into folders on Wed, 05 Jan 2022 15:19:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: michael-vincent">@<bdi>michael-vincent</bdi></a> said in <a href="/post/72672">Convenience technique when organizing PythonScripts into folders</a>:</p>
<blockquote>
<p dir="auto">Do you “share” them anywhere - GitHub for example?</p>
</blockquote>
<p dir="auto">Well, I share the ones that I think have general usage, or maybe something I’ve developed to answer a question here…and I share them, well, <em>here</em> on the Community.</p>
<p dir="auto">I’ve thought about gists on Github, but haven’t gone there with them as yet.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72674</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72674</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 05 Jan 2022 15:19:16 GMT</pubDate></item><item><title><![CDATA[Reply to Convenience technique when organizing PythonScripts into folders on Wed, 05 Jan 2022 15:14:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> said in <a href="/post/72311">Convenience technique when organizing PythonScripts into folders</a>:</p>
<blockquote>
<p dir="auto">but here’s what my Plugins &gt; PythonScript &gt; Scripts menu looks like:</p>
</blockquote>
<p dir="auto">WOW, that’s a lot of scripts!  Do you “share” them anywhere - GitHub for example?</p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72672</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72672</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Wed, 05 Jan 2022 15:14:25 GMT</pubDate></item><item><title><![CDATA[Reply to Convenience technique when organizing PythonScripts into folders on Wed, 22 Dec 2021 16:26:18 GMT]]></title><description><![CDATA[<p dir="auto">While we’re on this general subject, if I add this code in:</p>
<pre><code class="language-z">for p in sys.path:
    if not os.path.isdir(p):
        print(p)
</code></pre>
<p dir="auto">I see this (but leading paths removed) in the console after Notepad++ starts up:</p>
<pre><code class="language-z">...\npp.8.1.9.3.portable.x64\plugins\Config\PythonScript\lib
...\npp.8.1.9.3.portable.x64\plugins\PythonScript\lib\lib-tk
...\npp.8.1.9.3.portable.x64\plugins\PythonScript\python27.zip
...\npp.8.1.9.3.portable.x64\DLLs
...\npp.8.1.9.3.portable.x64\lib
...\npp.8.1.9.3.portable.x64\lib\plat-win
...\npp.8.1.9.3.portable.x64\lib\lib-tk
</code></pre>
<p dir="auto">Now, I don’t “install” PythonScript, and I don’t need Tk, so I don’t manually install that, but some of these others seem a bit oddball.</p>
<p dir="auto">Expecially the <code>DLLs</code> and <code>lib</code> ones, right off of the main N++ folder…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72318</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72318</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 22 Dec 2021 16:26:18 GMT</pubDate></item><item><title><![CDATA[Reply to Convenience technique when organizing PythonScripts into folders on Wed, 22 Dec 2021 16:17:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a></p>
<p dir="auto">I also use the following to add any python libraries to the PythonScript plugin install as well</p>
<pre><code>libDir = r'C:\\Notepad++\\plugins\\PythonScript\\lib'
try:
    sys.path.index(libDir)
except ValueError:
    sys.path.append(libDir)
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/72315</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72315</guid><dc:creator><![CDATA[Nick Brown]]></dc:creator><pubDate>Wed, 22 Dec 2021 16:17:33 GMT</pubDate></item></channel></rss>