Editing Python Names
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 4: | Line 4: | ||
The right answer is all the time, but in practice people go to more effort when they expect the program to be around for a longer time. Also in practice programs tend to be around longer than you expect. Try to develop good habits, it will pay off. | The right answer is all the time, but in practice people go to more effort when they expect the program to be around for a longer time. Also in practice programs tend to be around longer than you expect. Try to develop good habits, it will pay off. | ||
= Short vs Long = | = Short vs Long = | ||
− | Really short names are rarely good they just have too little meaning. You should remember that a program is more often read than written ( only once not counting fix up ) so make it easy to read. That said names can get too long. Over 12 characters?: take a second look. | + | Really short names are rarely good they just have too little meaning. You should remember that a program is more often read than written ( only once not counting fix up ) so make it easy to read. That said names can get too long. Over 12 characters?: take a second look. Abriviations are fine but should be consistent. I use hi and lo for high and low, max and min for maximinum and minimum. But n for number? Too short, also may hide an important function n(). |
− | Short vs long also applies to how long the variable will exist, or be in scope. If the scope of a variable is short, it is easier to live with a short, and less clear, name | + | Short vs long also applies to how long the variable will exist, or be in scope. If the scope of a variable is short, it is easier to live with a short, and less clear, name. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
= Avoid Reserved Words = | = Avoid Reserved Words = | ||
Line 74: | Line 30: | ||
def display_help(): # verb like | def display_help(): # verb like | ||
</pre> | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
= Class Instance Variables = | = Class Instance Variables = |