<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.bathcs.com/index.php?action=history&amp;feed=atom&amp;title=Python</id>
	<title>Python - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.bathcs.com/index.php?action=history&amp;feed=atom&amp;title=Python"/>
	<link rel="alternate" type="text/html" href="https://wiki.bathcs.com/index.php?title=Python&amp;action=history"/>
	<updated>2026-08-26T08:41:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wiki.bathcs.com/index.php?title=Python&amp;diff=202&amp;oldid=prev</id>
		<title>Pm2022: Pm2022 moved page BOSS/Languages/Python to Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.bathcs.com/index.php?title=Python&amp;diff=202&amp;oldid=prev"/>
		<updated>2026-08-26T07:03:22Z</updated>

		<summary type="html">&lt;p&gt;Pm2022 moved page &lt;a href=&quot;/wiki/BOSS/Languages/Python&quot; class=&quot;mw-redirect&quot; title=&quot;BOSS/Languages/Python&quot;&gt;BOSS/Languages/Python&lt;/a&gt; to &lt;a href=&quot;/wiki/Python&quot; title=&quot;Python&quot;&gt;Python&lt;/a&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:03, 26 August 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en-GB&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Pm2022</name></author>
	</entry>
	<entry>
		<id>https://wiki.bathcs.com/index.php?title=Python&amp;diff=199&amp;oldid=prev</id>
		<title>Pm2022: cat</title>
		<link rel="alternate" type="text/html" href="https://wiki.bathcs.com/index.php?title=Python&amp;diff=199&amp;oldid=prev"/>
		<updated>2026-08-26T06:59:58Z</updated>

		<summary type="html">&lt;p&gt;cat&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 06:59, 26 August 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l114&quot;&gt;Line 114:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 114:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   ...&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   ...&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Bath Open Source Society]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Programming language guidelines]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pm2022</name></author>
	</entry>
	<entry>
		<id>https://wiki.bathcs.com/index.php?title=Python&amp;diff=118&amp;oldid=prev</id>
		<title>Hw2210: Translate from boss.bathcs.com</title>
		<link rel="alternate" type="text/html" href="https://wiki.bathcs.com/index.php?title=Python&amp;diff=118&amp;oldid=prev"/>
		<updated>2026-06-04T08:01:46Z</updated>

		<summary type="html">&lt;p&gt;Translate from boss.bathcs.com&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Should follow [https://peps.python.org/pep-0008/ PEP-8]&lt;br /&gt;
&lt;br /&gt;
== Quick overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;4 spaces as tabs&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;snake_case&amp;lt;/code&amp;gt; for variables, functions and modules&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;PascalCase&amp;lt;/code&amp;gt; for classes&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Global variables should not be used.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Global constants should be in &amp;lt;code&amp;gt;SCREAMING_CASE&amp;lt;/code&amp;gt; when used.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Lines should not be longer than 80 characters&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Use trailing commas when the closing bracket is on a new line&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Space after comments e.g. &amp;lt;code&amp;gt;# something&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Protected methods and attributes to start with &amp;lt;code&amp;gt;_&amp;lt;/code&amp;gt;, private to start with &amp;lt;code&amp;gt;__&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;When a variable is not used, give it the name &amp;lt;code&amp;gt;_&amp;lt;/code&amp;gt; e.g.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;for _ in range(10):&lt;br /&gt;
    print(&amp;quot;Hi&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
(important_var, _) = some_func()&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Non-biased opinions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Try to prioritise readability of code&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Order imports alphabetically but split internal imports&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Comments should only be written when necessary, mainly to describe why something is done the way it is or to example a really unreadable bit of code (however this normally means you should change the code).&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Methods should be ordered alphabetically (with private methods ordered separately and at the bottom of the file) e.g.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;def a_func():&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
def b_func():&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
def z_func():&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
def _a_private_func():&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
def _b_private_func():&lt;br /&gt;
  ...&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Please use statically-typed code when possible: always for functions and parameters and then only for variables when its hard to tell e.g.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;MY_CONST: dict[str, set[list[(str|int)]]] = {&lt;br /&gt;
    &amp;quot;something&amp;quot;: set([&amp;quot;hi&amp;quot;], [2], [3]),&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
def my_func(param1: int, param2: list[str]) -&amp;gt; (dict[str, int]|None):&lt;br /&gt;
    my_variable = &amp;quot;hi&amp;quot;&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
def void_func():&lt;br /&gt;
    ...&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;However note that we should try to avoid using the &amp;lt;code&amp;gt;str|int&amp;lt;/code&amp;gt; type and keep to one type when possible.&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Generators are cool but don’t over use them and format them to be more readable with good naming schemes. e.g.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;py&amp;quot;&amp;gt;cube = np.from_iter((&lt;br /&gt;
    (y + x for x in range(10))&lt;br /&gt;
    for y in range(10)&lt;br /&gt;
), ...)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using Pylint ==&lt;br /&gt;
&lt;br /&gt;
On most IDEs (including vscode) you should be able to get a pylint extension to point out mistakes and annoy you into writing okay code. Please use this as it should help you with the above styling requirements.&lt;br /&gt;
&lt;br /&gt;
You can also use flake8 (however these are really strict and I don’t like some of them), so here is an example configuration (in the &amp;lt;code&amp;gt;.flake8&amp;lt;/code&amp;gt; file):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;toml&amp;quot;&amp;gt;[flake8]&lt;br /&gt;
extend-ignore = E272,E221,E227,E201,E202&lt;br /&gt;
exclude = .git,__pycache__&lt;br /&gt;
max-complexity = 10&amp;lt;/pre&amp;gt;&lt;br /&gt;
== Documentation ==&lt;br /&gt;
&lt;br /&gt;
There is annoyingly no exact style in python for these… Here is something I kinda like.&lt;br /&gt;
&lt;br /&gt;
Documentation should be for all public modules, methods, classes and functions (however please also try to do them for private versions, but they don’t have to be as indepth).&lt;br /&gt;
&lt;br /&gt;
The style of documentation is kinda whatever you want it to be, so here is a somewhat okay layout. (Any better styles are most welcome as long as we are consistent)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
example_module.py&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
Description&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
def my_func(param1: int) -&amp;gt; str:&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Description of return which fits in less than 80 chars&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
def my_complex_func(param1: list[str]):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Description&lt;br /&gt;
&lt;br /&gt;
    Parameters&lt;br /&gt;
    ----------&lt;br /&gt;
    param1 (type): Description&lt;br /&gt;
&lt;br /&gt;
    Return&lt;br /&gt;
    ------&lt;br /&gt;
    brief_name (type): Description&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
class MyClass:&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  Description&lt;br /&gt;
&lt;br /&gt;
  Attributes&lt;br /&gt;
  ----------&lt;br /&gt;
  ...&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  def my_method():&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;...&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hw2210</name></author>
	</entry>
</feed>