You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
- 56Excellent advice. However I can't upvote for the "that is not so bad" comment. It is so bad. Low quality scientific scripts are a big issue for reproducibility in data analysis and a frequent source of error in analysis. Writing good code is valuable not just so that you can understand it later but also so that you can avoid errors in the first place.anon– anon2018-07-06 13:24:46 +00:00Commented Jul 6, 2018 at 13:24
- 26If the code is an implementation of a well-known formula, then single-letter variable names and such might be the right thing to do. Depends on the audience...and more to the point, whether the reader is expected to already know what the names mean.cHao– cHao2018-07-06 14:27:43 +00:00Commented Jul 6, 2018 at 14:27
- 13@cHao the problem is not when those variables are plugged in the formula (hence the "rename them inside the function" advice), but when they're read and manipulated outside of it, and when they start conflicting with other variables down the line (for example, I've seen people in need of three "x" variables name them x1, x2, x3)BgrWorker– BgrWorker2018-07-06 14:37:51 +00:00Commented Jul 6, 2018 at 14:37
- 5"I'm gonna go against common sense..." No you're not. You're going against the prevailing dogma, which is itself against common sense. ;) This is all perfectly sound advice.jpmc26– jpmc262018-07-06 22:52:31 +00:00Commented Jul 6, 2018 at 22:52
- 3As a (former) scientific programmer, I generally adopt a rule of three. If I end up writing similar code three times, the functionality gets fleshed out and written up in a separate module with documentation (often just comments, but that's sufficient). This limits the chaos of ad-hoc programming, and allows me to build up a library that I can expand on in the future.rcollyer– rcollyer2018-07-09 14:39:10 +00:00Commented Jul 9, 2018 at 14:39
| Show 11 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-py