Pick one and be consistent. I write Python a lot, therefore I would choose the Python style, which is concerned with readability for non-native-English speakers. However, reasonable people could disagree. Build concensus on your team, and take what you can best agree to be the best course of action.
How to work with coding styles clashe within a single project across different languages? [closed]
-
18-06-2023 - |
Domanda
In Python underscores are used for variables:
some_long_var, my_name, first_name, etc.
In JavaScript camelcase is preferred:
someLongVar, myName, firstName, etc.
All is fine and dandy until the two technologies start interacting:
JS Ajax Call:
$.get('url', {foo_bar: fooBar, bar_baz: barBaz}).done(function (data) {
console.log(data.computed_result);
};
Python view:
def url():
foo_bar = request.GET.get('foo_bar')
bar_baz = request.GET.get('bar_baz')
return jsonify(computed_result=foo_bar + bar_baz)
Do I use the Python or the JS style within the data JSON object sent to the server?
What about the JSON response?
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow