PEP-8, Line Length, And All That

Cameron Simpson cs at cskk.id.au
Sat Jan 21 18:50:01 EST 2023


On 21Jan2023 01:32, Thomas Passin <list1 at tompassin.net> wrote:
>In another thread ("Improvement to imports, what is a better way ?") 
>there was a lot of talk about line length, PEP-8, etc.  I realized 
>that one subject did not really come up, yet it can greatly affect the 
>things we were talking about.
>
>I'm referring to the design of the functions, methods, and classes. 
>When they are well designed, or more likely, refactored over and over 
>again, they can lead to code that reads almost like pseudo-code.  [...]

Yeah. Personally, I summarise this as the maxim: "ergonomics matter".  
Code should be easy to use and easy to read.

I've got a heap of code I've refactored after the initial implementation 
to make it easy to use, if only to make it easier for _me_ to use to do 
more things with it.

I've also got decorators and context managers and special classes all 
aimed at making all the things easier to use and easier to _write_ 
(because some decorators (a) provide flexibility for the caller - easier 
to use and (b) implement standard boilerplate logic for common types of 
parameters, making the function/method implementation easier to write.)

And increasingly I've got docstrings with _example_ code which doubles 
as a doctest. Making it easier to understand how to easily use this 
thing.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list