Re: Pep8 for long pattern
On 27/03/18 22:02, Dan Stromberg wrote: On Tue, Mar 27, 2018 at 8:18 AM, Michael Torriewrote: But when it's exactly what you need, why do you need to shoehorn the expression into 79 characters? Seems pointless in a case like this. PEP8 is a guideline, not an absolute rule. It's okay to bend it a bit in cases like this. I think PEP8 specifying a max of 80 columns is very silly. Even an old VT220 terminal could do 132 columns. At the risk of starting the Yorkshiremen sketch again, the *old* terminals couldn't :-) The BBC Micros we used as terminals to the mainframe could be made to give you more columns, but no one was that masochistic. My understanding is that PEP8 requires 80 columns because a tiny, tiny, tiny minority of Python developers wanted to be able to put 3 editors next to each other horizontally, without wrapping. Hi :-) I like to check my code with pycodestyle, but I always override that dang 80 column requirement. Very rarely I will let a line leak past 80 characters when it really doesn't make any sense to break it up into smaller chunks. I'm fine with other people going longer if they're fine with me reformatting their code if I have to work on it. -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list
Re: Pep8 for long pattern
On Tuesday, March 27, 2018 at 9:37:14 PM UTC-5, Dan Stromberg wrote: > I can easily get 132+ columns of a font large enough for my > 52 year old eyes on a 15" laptop. Well, if you're comfortable with the long lines, fine. But be aware that long lines are poo-pooed in most professional enviroments. > 80 is actually a bit defeatist, because it discourages > developers from using more descriptive identifiers. I'm a big fan of self-documenting code. But sometimes i have to remind myself that really long names make the code harder to read. The wise find a nice balance between readability and self-documenting. And unless you're a masochist, don't look to Microsoft for inspiration! Another reason for 80 char limit is to prevent deeply nested blocks. At the PEP8 recommended four-space-indention, three blocks is about all you can get. And that's good enough for me. -- https://mail.python.org/mailman/listinfo/python-list
Re: Pep8 for long pattern
On Tue, Mar 27, 2018 at 4:37 PM, Rick Johnsonwrote: > On Tuesday, March 27, 2018 at 4:02:37 PM UTC-5, Dan Stromberg wrote: >> On Tue, Mar 27, 2018 at 8:18 AM, Michael Torrie wrote: >> > But when it's exactly what you need, why do you need to >> > shoehorn the expression into 79 characters? Seems >> > pointless in a case like this. PEP8 is a guideline, not an >> > absolute rule. It's okay to bend it a bit in cases like >> > this. >> >> I think PEP8 specifying a max of 80 columns is very silly. >> Even an old VT220 terminal could do 132 columns. > > And just think how many columns you could do with 1pt font! > And while i admit i enjoy coding with my nose pressed > against the monitor as much as the next "guyal"[1], just uh, > be sure to keep a good optometrist on retainer, eh pal? I realize you're just trying to be a pest, but some folks will take your words seriously. I can easily get 132+ columns of a font large enough for my 52 year old eyes on a 15" laptop. >> My understanding is that PEP8 requires 80 columns because a >> tiny, tiny, tiny minority of Python developers wanted to be >> able to put 3 editors next to each other horizontally, >> without wrapping. > > Stacking horizontal windows three deep is all the rage, but > the reason has more to do with easy reading. Long lines are > difficult to read. And when your eyes do a linefeed at the > end of a 200 character long line, there's no guarantee > you'll end up starting on the next line. Sometimes you'll > find yourself three lines down, while others, back at the > start of the same line. And that's annoying. Again, you're just trying to be a pest, but no one is asking for 10,000,000 columns. 120 or 132 would be good. 80 is actually a bit defeatist, because it discourages developers from using more descriptive identifiers. -- https://mail.python.org/mailman/listinfo/python-list
Re: Pep8 for long pattern
On Tuesday, March 27, 2018 at 4:02:37 PM UTC-5, Dan Stromberg wrote: > On Tue, Mar 27, 2018 at 8:18 AM, Michael Torriewrote: > > But when it's exactly what you need, why do you need to > > shoehorn the expression into 79 characters? Seems > > pointless in a case like this. PEP8 is a guideline, not an > > absolute rule. It's okay to bend it a bit in cases like > > this. > > I think PEP8 specifying a max of 80 columns is very silly. > Even an old VT220 terminal could do 132 columns. And just think how many columns you could do with 1pt font! And while i admit i enjoy coding with my nose pressed against the monitor as much as the next "guyal"[1], just uh, be sure to keep a good optometrist on retainer, eh pal? > My understanding is that PEP8 requires 80 columns because a > tiny, tiny, tiny minority of Python developers wanted to be > able to put 3 editors next to each other horizontally, > without wrapping. Stacking horizontal windows three deep is all the rage, but the reason has more to do with easy reading. Long lines are difficult to read. And when your eyes do a linefeed at the end of a 200 character long line, there's no guarantee you'll end up starting on the next line. Sometimes you'll find yourself three lines down, while others, back at the start of the same line. And that's annoying. > I like to check my code with pycodestyle, but I always > override that dang 80 column requirement. Certainly your decision. But please do try to maintain as much of PEP8 as you can tolerate. Most of it (~75%) is really good advice. [1] "guy" and/or "gal" = "guyal" -- https://mail.python.org/mailman/listinfo/python-list
Re: Pep8 for long pattern
On Tue, Mar 27, 2018 at 8:18 AM, Michael Torriewrote: > But when it's exactly what you need, why do > you need to shoehorn the expression into 79 characters? Seems pointless > in a case like this. PEP8 is a guideline, not an absolute rule. It's > okay to bend it a bit in cases like this. I think PEP8 specifying a max of 80 columns is very silly. Even an old VT220 terminal could do 132 columns. My understanding is that PEP8 requires 80 columns because a tiny, tiny, tiny minority of Python developers wanted to be able to put 3 editors next to each other horizontally, without wrapping. I like to check my code with pycodestyle, but I always override that dang 80 column requirement. -- https://mail.python.org/mailman/listinfo/python-list
Re: Pep8 for long pattern
On 03/27/2018 08:17 AM, Ganesh Pal wrote: > Hello Python friends, > > How do I split the below regex , so that it fits within the character > limit of 79 words > > > pattern = [ > r'(?P([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', > > r'(?P(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', > '.'] > > I am using Python 2.7 + Linux I like Serhiy's idea of using fixed number repetition to shorten the expressions and make them more readable. Now it could be that in general a long regular expression is a bad idea (maybe a simple split() is the way to go instead). But when it's exactly what you need, why do you need to shoehorn the expression into 79 characters? Seems pointless in a case like this. PEP8 is a guideline, not an absolute rule. It's okay to bend it a bit in cases like this. -- https://mail.python.org/mailman/listinfo/python-list
Re: Pep8 for long pattern
27.03.18 17:17, Ganesh Pal пише: How do I split the below regex , so that it fits within the character limit of 79 words pattern = [ r'(?P([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', r'(?P(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', '.'] For example: pattern = [ r'(?P(' r'[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:' r':HEAD))', r'(?P(owner:\s+' r'[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:' r':HEAD))', '.'] Or just use fixed number repetition: pattern = [ r'(?P((?:[0-9a-fA-F]+:){5}:HEAD))', r'(?P(owner:\s+(?:[0-9a-fA-F]+:){5}:HEAD))', '.'] -- https://mail.python.org/mailman/listinfo/python-list
Re: Pep8 for long pattern
Use re.X - see https://docs.python.org/3.6/library/re.html#re.X for details. On 27 March 2018 at 15:17, Ganesh Palwrote: > Hello Python friends, > > How do I split the below regex , so that it fits within the character > limit of 79 words > > > pattern = [ > r'(?P([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', > > r'(?P(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', > '.'] > > I am using Python 2.7 + Linux > > Regards, > Ganesh > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Pep8 for long pattern
Hello Python friends, How do I split the below regex , so that it fits within the character limit of 79 words pattern = [ r'(?P([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', r'(?P(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', '.'] I am using Python 2.7 + Linux Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list