El dom, 7 feb 2021 a las 9:38, Jonathan Crall (<erotemic@gmail.com>) escribió:
Currently my timerit package requires syntax like:
import timerit for timer in timerit.Timerit(num=100, bestof=3, verbose=1): with timer: [code]
But that could be simplified to
import timerit for timer in timerit.Timerit(num=100, bestof=3, verbose=1) with timer: [code]
Only if you don't setup vars like oficial example* or not calc some statistic after timered block * https://timerit.readthedocs.io/en/latest/#timerit-documentation
And free up one level of indentation (very useful if you are trying to keep under 80 chars per line)
In your example this is true by luck: import timerit class MyClass: def myfunc(): # Next line is 79 chars long, at limit of restricted pep8 for timer in timerit.Timerit(num=100, bestof=3, verbose=1) with timer: [code] I usually have identation "problems" in ifs, sometimes in for clauses. I usually have not problems in function bodys. I dislike compacted form because: - i doubt that is good comply their objetive: reduce line length in body but extend it in control flow lines. - It's less readable for me. I need to attend to long lines to determine control flow. - Refactors are complicated. Think in add a initialization block in your example and how many lines are changed to be reviewed by your peers. - It's syntactic sugar for only some marginal edge cases: it cloying the language Anyway pep8** says: Some teams strongly prefer a longer line length. For code maintained exclusively or primarily by a team that can reach agreement on this issue, *it is okay to increase the line length limit up to 99 characters*, provided that comments and docstrings are still wrapped at 72 characters. ** https://www.python.org/dev/peps/pep-0008/#maximum-line-length So, if 79 chars by line it's too hard for your team you can agree 99 chars lines with your team. Maybe you find problems in: - web documentation that includes fixed designs for 79 chars (usually you can use other theme) - errors in linters (can be configured to new line width) - forcing horizontal scroll in 3ways merges for some team members ¯\_(ツ)_/¯ rarely you find problems by terminal widths (this is a very ancient problem resolved in our century). So I recomend you relaxed pep8 with 99 chars limit by line in your code instead to pretend change syntax with no clear gains. regards, Javi