Skip to content

Commit f9ac22c

Browse files
committed
Style guide improvements.
1 parent ffa5dc4 commit f9ac22c

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

STYLE_GUIDE.rst

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,27 @@
11
STYLE GUIDE
22
==============
33

4-
Use your common sense and have some decency. Also try to stick to the following where reasonable.
4+
As a rough style guide, please lint your code with pep8::
55

6+
pip install pep8
7+
pep8 --ignore E501,E226,E241 sc2reader
68

7-
Absolute Imports
8-
----------------------
99

10-
Always use absolute imports::
10+
All files should start with the following::
1111

12-
from __future__ import absolute_import
12+
# -*- coding: utf-8 -*-
13+
#
14+
# Optional Documentation on the module
15+
#
16+
from __future__ import absolute_import, print_function, unicode_literals, division
1317

14-
That means imports should always start with sc2reader... instead of being relative to the current module.
18+
All imports should be absolute.
1519

16-
from sc2reader.utils import ReplayBuffer
1720

21+
All string formatting sound be done in the following style::
1822

19-
Explicit Imports
20-
---------------------
23+
"my {0} formatted {1} string {2}".format("super", "python", "example")
24+
"the {x} style of {y} is also {z}".format(x="dict", y="arguments", z="acceptable")
2125

22-
Prefer explicit imports to globbed imports
23-
24-
from sc2reader.events import ChatEvent
25-
26-
is better than
27-
28-
from sc2reader.events import *
29-
30-
31-
Formatting Strings
32-
-----------------------
33-
34-
Use string.format(args) instead string % (args).
35-
36-
To support python 2.6, use numerical indexes even though it is a pain in the ass::
37-
38-
"{0} minerals, {1} gas, {2} terrazine, and {3} custom".format(self.minerals, self.vespene, self.terrazine, self.custom)
26+
The format argument index numbers are important for 2.6 support. ``%`` formatting is not allowed for 3.x support
3927

0 commit comments

Comments
 (0)