r/Python • u/RickSore • Nov 14 '17
Senior Python Programmers, what tricks do you want to impart to us young guns?
Like basic looping, performance improvement, etc.
1.3k
Upvotes
r/Python • u/RickSore • Nov 14 '17
Like basic looping, performance improvement, etc.
2
u/stevenjd Nov 15 '17
The 80 character limit has nothing to do with the width of the screen. It has to do with readability. Something like 70-90 characters is the upper limit for maximum readability, beyond that it is harder and slower for the eyes to track across the line without error.
You can probably get away with it if only a small proportion of lines reach 120 characters, say less than 10% of the code and no more than four in a row, but if you're reading code that regularly hits the 120 character limit, your reading is probably suffering, and the code probably sucks.
But then, if you're regularly hitting 80 columns, the code probably sucks too:
too many deeply nested blocks;
excessively long names (not every method should be called "doit", but neither should they be called "DoTheSameChangeInShopThenDoTheSameChangeInInventoryForNotChangedDataInInventory";
too many Law of Demeter violations (some might say even one is too many);
etc. Wide code is a code smell.