diff options
Diffstat (limited to 'thoughts/syntax')
-rw-r--r-- | thoughts/syntax/random-python-idiosyncrasies.html | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/thoughts/syntax/random-python-idiosyncrasies.html b/thoughts/syntax/random-python-idiosyncrasies.html index ba88071..fd2336d 100644 --- a/thoughts/syntax/random-python-idiosyncrasies.html +++ b/thoughts/syntax/random-python-idiosyncrasies.html @@ -87,6 +87,7 @@ <li><a href="#tabs-are-four-spaces-and-spaces-are-always-preferred-to-tabs">3) Tabs are four spaces and spaces are <em>ALWAYS</em> preferred to tabs</a></li> <li><a href="#always-add-spaces-between-arithmetic-but-never-for-brackets">4) Always add spaces between arithmetic, but never for brackets</a></li> <li><a href="#everything-should-be-snake_case">5) EVERYTHING should be snake_case</a></li> +<li><a href="#if-its-over-100-lines-you-probably-need-a-new-file-and-a-class">6) If it's over 100 lines, you probably need a new file (and a class)</a></li> </ul></li> </ul> </nav> @@ -149,5 +150,10 @@ <div class="sourceCode" id="cb9"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true"></a><span class="co"># this doesn't actually work, but you get the idea</span></span> <span id="cb9-2"><a href="#cb9-2" aria-hidden="true"></a>r <span class="op">=</span> requests.get(<span class="st">"www.debian.org"</span>)</span> <span id="cb9-3"><a href="#cb9-3" aria-hidden="true"></a>pageSize <span class="op">=</span> r.json()[<span class="st">'pageSize'</span>] <span class="co"># camel case ok</span></span></code></pre></div> +<h2 id="if-its-over-100-lines-you-probably-need-a-new-file-and-a-class">6) If it's over 100 lines, you probably need a new file (and a class)</h2> +<p>This is more of a general coding thing, but I've encountered so many 1000 line monster out there, I need to reiterate it. I understand how these things come to be, having made a few myself in the beginning. You get an idea and want to see it through in full. Like <em>On the Road</em> it comes out as a scroll Merlin himself would be proud of.</p> +<p>But coming back to the scroll in a week half-drunk and half-tired is not a situation you want to be caught in. You can always import <em>any</em> python code you write with a simple:</p> +<div class="sourceCode" id="cb10"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true"></a><span class="im">import</span> filename</span></code></pre></div> +<p>As long as it's in the same directory.</p> </body> </html> |