dcwatson / bbcode

A pure python bbcode parser and formatter.
BSD 2-Clause "Simplified" License
68 stars 17 forks source link

Problem: lines too looong #20

Closed obestwalter closed 8 years ago

obestwalter commented 9 years ago

Would you accept a PR with PEP8 conform line lengths?

obestwalter commented 9 years ago

Anyway - here it is: https://github.com/dcwatson/bbcode/pull/21

dcwatson commented 9 years ago

Just curious - what's the motivation? Personally, I can't stand the 79-character limit defined by PEP8. I've read some thoughtful pieces suggesting I suck it up and conform, but for my code, I prefer 120. That said, I'm open to hearing your motivation, especially since I haven't been good about enforcing even a 120-character limit myself here.

obestwalter commented 9 years ago

Lots of reasons. A lot of them are already given in the section about maximum line length of PEP8.

Limiting the required editor window width makes it possible to have several files open side-by-side, and works well when using code review tools that present the two versions in adjacent columns.

To take an example from this repo: https://github.com/dcwatson/bbcode/blob/master/bbcode.py#L138 This gets cut off in my browser and I have to start scrolling vertically. This makes me sad.

The default wrapping in most tools disrupts the visual structure of the code, making it more difficult to understand.

Another example from this repo: https://github.com/dcwatson/bbcode/pull/21/files#r37240563 I am a side by side diff kind of guy, so this is another reason for me why I just love the 79 char limit, even when at times it makes me mad to stick with it myself, But I just learned to appreciate the advantages much more than the downsides over the years.

Also: in open source code it's much easier to stick to a well established standard if you don't have a very good reason not to. This saves everybody involved from having to negotiate the basics over and over again. In Python luckily PEP8 is quite established. The only thing I don't like is the slug case for all names. In my own code I use camelCase for things that act like variables (names and properties) and slug case for callables.

I found as well, that having the restriction of shorter lines is one factor that forces me to structure my code better. This is a bit fuzzy and I have never tried to explain exactly, why I think this is the case - it's more a feeling. One part of it is definitely, that when I have too much vertical space I tend to cram too much onto one line and that is usually not a good thing.

For me sticking with PEP8 is just a no brainer nowadays. I use PyCharm and have PEP8 checks on and set to error, so if I open a file that does not comply to PEP8 my toes start to curl up right away, because there are a lot of red markers :)

Feel free to decline the PR if it does not make sense to you - it's your project after all. I did it, because I integrated your code in one of my projects, so this was the first step before I integrated it.

obestwalter commented 8 years ago

There are more important things in live than squabbling over line length :) - I removed my fork containing the pull request, so I am closing this also.