Re: Python 3 regex?

2015-01-14 Thread Steven D'Aprano
Thomas 'PointedEars' Lahn wrote: wxjmfa...@gmail.com wrote: [...] And, why not? compare Py3.2 and Py3.3+ ! What are you getting at? Don't waste your time with JMF. He is obsessed with a trivial performance regression in Python 3.3. Unicode strings can be slightly more expensive to create

Re: Python 3 regex?

2015-01-14 Thread Rustom Mody
On Tuesday, January 13, 2015 at 10:06:50 AM UTC+5:30, Steven D'Aprano wrote: On Mon, 12 Jan 2015 19:48:18 +, Ian wrote: My recommendation would be to write a recursive decent parser for your files. That way will be easier to write, I know that writing parsers is a solved problem

Re: Python 3 regex?

2015-01-14 Thread alister
On Wed, 14 Jan 2015 14:02:27 +0100, Thomas 'PointedEars' Lahn wrote: wxjmfa...@gmail.com wrote: Le mardi 13 janvier 2015 03:53:43 UTC+1, Rick Johnson a écrit : [...] you should find Python's text processing Nirvana [...] I recommend, you write a small application I recommend you get

Re: Python 3 regex?

2015-01-14 Thread Rustom Mody
On Tuesday, January 13, 2015 at 10:06:50 AM UTC+5:30, Steven D'Aprano wrote: On Mon, 12 Jan 2015 19:48:18 +, Ian wrote: My recommendation would be to write a recursive decent parser for your files. That way will be easier to write, I know that writing parsers is a solved problem

Re: Python 3 regex?

2015-01-14 Thread Thomas 'PointedEars' Lahn
wxjmfa...@gmail.com wrote: Le mardi 13 janvier 2015 03:53:43 UTC+1, Rick Johnson a écrit : [...] you should find Python's text processing Nirvana [...] I recommend, you write a small application I recommend you get a real name and do not post using the troll and spam- infested Google

Re: Python 3 regex?

2015-01-13 Thread Rick Johnson
On Tuesday, January 13, 2015 at 11:09:17 AM UTC-6, Rick Johnson wrote: [...] DO YOU NEED ME TO DRAW YOU A PICTURE? I don't normally do this, but in the interest of education i feel i must bear the burdens for which all professional educators like myself are responsible.

Re: Python 3 regex?

2015-01-13 Thread Rick Johnson
On Tuesday, January 13, 2015 at 12:39:55 AM UTC-6, Steven D'Aprano wrote: On Mon, 12 Jan 2015 15:47:08 -0800, Rick Johnson wrote: [...] [...] #Ironic Twist (Reformatted)#

Re: Python 3 regex?

2015-01-13 Thread Jussi Piitulainen
alister alister.nospam.w...@ntlworld.com writes: On Tue, 13 Jan 2015 04:36:38 +, Steven D'Aprano wrote: On Mon, 12 Jan 2015 19:48:18 +, Ian wrote: My recommendation would be to write a recursive decent parser for your files. That way will be easier to write, I know

Re: Python 3 regex?

2015-01-13 Thread alister
On Tue, 13 Jan 2015 04:36:38 +, Steven D'Aprano wrote: On Mon, 12 Jan 2015 19:48:18 +, Ian wrote: My recommendation would be to write a recursive decent parser for your files. That way will be easier to write, I know that writing parsers is a solved problem in computer science,

Re: Python 3 regex woes (parsing ISC DHCPD config)

2015-01-13 Thread Thomas 'PointedEars' Lahn
Jason Bailey wrote: My script first reads the DHCPD configuration file into memory - variable filebody. It then utilizes the re module to find the configuration details for the wanted shared network. The config file might look something like this: ##

Re: Python 3 regex woes (parsing ISC DHCPD config)

2015-01-13 Thread Thomas 'PointedEars' Lahn
Thomas 'PointedEars' Lahn wrote: Jason Bailey wrote: shared-network My-Network-MOHE { […] { I compile my regex: m = re.compile(r^(shared\-network ( + re.escape(shared_network) + r) \{((\n|.|\r\n)*?)(^\})), re.MULTILINE|re.UNICODE) This code does not run as posted. Applying Occam’s

Re: Python 3 regex?

2015-01-13 Thread Rick Johnson
On Monday, January 12, 2015 at 11:34:57 PM UTC-6, Mark Lawrence wrote: You snipped the bit that says [normal cobblers snipped]. Oh my, where are my *manners* today? Tell you what, next time when your sneaking up behind me with a knife in hand, do be a friend and tap me on the shoulder first, so

Re: Python 3 regex?

2015-01-12 Thread Ian
On 12/01/2015 18:03, Jason Bailey wrote: Hi all, I'm working on a Python _3_ project that will be used to parse ISC DHCPD configuration files for statistics and alarming purposes (IP address pools, etc). Anyway, I'm hung up on this one section and was hoping someone could provide me with

Re: Python 3 regex?

2015-01-12 Thread Chris Angelico
On Tue, Jan 13, 2015 at 5:03 AM, Jason Bailey jbai...@emerytelcom.com wrote: Unfortunately, I get no matches. From output on the command line, I can see that Python is adding extra backslashes to my re.compile string. I have added the raw 'r' in front of the strings to prevent it, but to no

Re: Python 3 regex woes (parsing ISC DHCPD config)

2015-01-12 Thread Dave Angel
On 01/12/2015 01:20 PM, Jason Bailey wrote: Hi all, What changed between 1:03 and 1:20 that made you post a nearly identical second message, as a new thread? Unfortunately, I get no matches. From output on the command line, I can see that Python is adding extra backslashes to my

Re: Python 3 regex?

2015-01-12 Thread Chris Angelico
On Tue, Jan 13, 2015 at 6:48 AM, Ian hobso...@gmail.com wrote: My recommendation would be to write a recursive decent parser for your files. That way will be easier to write, much easier to modify and almost certainly faster that a RE solution - and it can easily give you all the information

Re: Python 3 regex woes (parsing ISC DHCPD config)

2015-01-12 Thread Albert-Jan Roskam
- Original Message - From: Jason Bailey jbai...@emerytelcom.com To: python-list@python.org Cc: Sent: Monday, January 12, 2015 7:20 PM Subject: Python 3 regex woes (parsing ISC DHCPD config) Hi all, I'm working on a Python _3_ project that will be used to parse ISC DHCPD

Re: Python 3 regex?

2015-01-12 Thread Rick Johnson
'Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems.' - Jamie Zawinski. This statement is one of my favorite examples of powerful propaganda, which has scared more folks away from regexps than even the Upright Citizens Brigade

Re: Python 3 regex?

2015-01-12 Thread Chris Angelico
On Tue, Jan 13, 2015 at 10:47 AM, Rick Johnson rantingrickjohn...@gmail.com wrote: WHO'S LAUGHING NOW? -- YOU MINDLESS ROBOTS! It's very satisfying when mindless robots laugh. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3 regex?

2015-01-12 Thread Rick Johnson
On Monday, January 12, 2015 at 7:55:32 PM UTC-6, Mark Lawrence wrote: On 12/01/2015 23:47, Rick Johnson wrote: 'Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems.' - Jamie Zawinski. [snip] If you wish to use a hydrogen

Re: Python 3 regex?

2015-01-12 Thread Mark Lawrence
On 12/01/2015 23:47, Rick Johnson wrote: 'Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems.' - Jamie Zawinski. [normal cobblers snipped] If you wish to use a hydrogen bomb instead of a tooth pick feel free, I won't lose

Re: Python 3 regex?

2015-01-12 Thread Steven D'Aprano
On Mon, 12 Jan 2015 19:48:18 +, Ian wrote: My recommendation would be to write a recursive decent parser for your files. That way will be easier to write, I know that writing parsers is a solved problem in computer science, and that doing so is allegedly one of the more trivial things

Re: Python 3 regex?

2015-01-12 Thread Mark Lawrence
On 13/01/2015 02:53, Rick Johnson wrote: On Monday, January 12, 2015 at 7:55:32 PM UTC-6, Mark Lawrence wrote: On 12/01/2015 23:47, Rick Johnson wrote: 'Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems.' - Jamie Zawinski.

Re: Python 3 regex?

2015-01-12 Thread Steven D'Aprano
On Mon, 12 Jan 2015 15:47:08 -0800, Rick Johnson wrote: 'Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems.' - Jamie Zawinski. I wonder if Jamie's conclusions are a result of careful study, or merely, an attempt to resolve

Python 3 regex?

2015-01-12 Thread Jason Bailey
Hi all, I'm working on a Python _3_ project that will be used to parse ISC DHCPD configuration files for statistics and alarming purposes (IP address pools, etc). Anyway, I'm hung up on this one section and was hoping someone could provide me with some insight. My script first reads the

Python 3 regex woes (parsing ISC DHCPD config)

2015-01-12 Thread Jason Bailey
Hi all, I'm working on a Python _3_ project that will be used to parse ISC DHCPD configuration files for statistics and alarming purposes (IP address pools, etc). Anyway, I'm hung up on this one section and was hoping someone could provide me with some insight. My script first reads the