Spaces should never, ever be before the first non-whitespace character on a line. Tabs should never, ever be after the first non-whitespace character on a line.
Put another way, all lines should match the following regex:
^[\t]*\S[^\t]*$|^$
(i.e. a blank line, or 0 or more tabs followed by 1 a non-white-space character followed by 0 or more non-tab characters)
class User(db.Model):
id = db.Column(db.Integer)
group_id = db.Column(db.Integer)
group = db.relationship('Group', lazy='join', backref=db.backref('users', use_list=True))
Should it look like this:
class User(db.Model):
id = db.Column(db.Integer)
group_id = db.Column(db.Integer)
group = db.relationship(
'Group',
lazy='join',
backref=db.backref('users', use_list=True)
)
or this:
class User(db.Model):
id = db.Column(db.Integer)
group_id = db.Column(db.Integer)
group = db.relationship('Group', lazy='join',
backref=db.backref('users', use_list=True))
Both of those examples fit within PEP-8, so there's not need to start language wars like this:
That looks like what I imagine python folks would write to try and cope with a c-style language.
I would argue that good programmers adjust their style depending on the language. For example, use snake_case in Python, and camelCase in JavaScript for variable names.
[Also, arguably the ugliest Python are the libraries that are written in Java style -- e.g. unittest in the standard library -- since they look nothing like the style of everything else.]
3
u/Asmor Mar 27 '15
Well, pretty simple.
Spaces should never, ever be before the first non-whitespace character on a line. Tabs should never, ever be after the first non-whitespace character on a line.
Put another way, all lines should match the following regex:
(i.e. a blank line, or 0 or more tabs followed by 1 a non-white-space character followed by 0 or more non-tab characters)
Example of usage of spaces for alignment: