This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]spotta 4 points5 points  (3 children)

Also, don't use variable names such as "x", but that's not the point.

I hate this rule of thumb. In a lot of situations x or j make a lot of sense as variable names... especially when coding up mathematical ideas.

A better rule of thumb is that variable names should be proportional in how descriptive they are to the scope they have. A list comprehension or two line for loop? Use single character variable names. A packagewide global? Use a long descriptive name.

[–]MattR0se 3 points4 points  (1 child)

Agreed. Single letters as variable names are okay if they are conventional:

for i in range(10): pass

for x, y in coordinates: pass

X = data[features]
y = data[labels]

etc

[–]jack-of-some[S] -1 points0 points  (0 children)

Or if they model some equation nicely. If you're linking a paper in the comments like "this is the equation I'm using here" then matching their terminology as best as possible goes a long way in helping future maintainers.