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.]
Well, both examples may fit within PEP8, but in my book there is a world of difference between this:
my_long_function_name(arg1,
arg2)
And this:
my_long_function_name(
arg1,
arg2)
Whoch I think is the distinction the earlier poster was pointing out. Aligning arguments like in example 1 looks fine I guess, but once you start regex reformatting then you'll have to make a bunch of pointless, waste of time whitespace changes.
Both Vim and Emacs have modes that do well with Python indenting rules, so as long as you have the right tool for the job, I'm sure it would be fine. If the linters can detect these differences, I'm sure that tools will be fine (especially since Python exposes AST in the standard library).
Also, the long function name with two short args is a bad example. It's obviously not pleasing on the eye because of the imbalance of the text (at least to me).
My original point though was that you are trying to state that your indentation rules are actually dictating you style choices. Not everyone agrees with that.
My point was that if you use names to dictate whitespace, your code will get screwed up when you refactor. Even if it's by hand, you'll spend a lot of unnecessary time on the spacebar or backspace.
The long function name with two short args is a completely typical example. The function name was long because it illustrates the problem, the function names were short because I'm lazy and on mobile.
Your indentation rules are actually dictating your style choices
2
u/pyr3 Mar 27 '15 edited Mar 27 '15
A better example of the second one:
Should it look like this:
or this:
Both of those examples fit within PEP-8, so there's not need to start language wars like this:
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.
unittestin the standard library -- since they look nothing like the style of everything else.]