Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #83662

Re: Python 3 regex?

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Python 3 regex?
Date 2015-01-13 05:34 +0000
References <54B40C85.5000806@emerytelcom.com> <mailman.17635.1421092112.18130.python-list@python.org> <4043d09b-05b2-4dc2-8a6b-bae2d53cd01f@googlegroups.com> <mailman.17649.1421114112.18130.python-list@python.org> <7c648fa2-4a59-4d1a-923f-d29f4f2dc8f7@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.17656.1421127286.18130.python-list@python.org> (permalink)

Show all headers | View raw


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.
>>>
>>
>> [snip]
>>
>> If you wish to use a hydrogen bomb instead of a tooth pick
>> feel free, I won't lose any sleep over it.  Meanwhile I'll
>> get on with writing code, and for the simple jobs that can
>> be completed with string methods I'll carry on using them.
>> When that gets too complicated I'll reach for the regex
>> manual, knowing full well that there's enough data in
>> books and online to help even a novice such as myself get
>> over all the hurdles. If that isn't good enough then maybe
>> a full blown parser, such as the pile listed here [snip]
>
> Mark, if you're going to quote me, then at least quote me in
> a manner that does not confuse the content of my post. The
> snippet you posted was not a statement of mine, rather, it
> was a quote that i was responding to, and without any
> context of my response, what is the point of quoting
> anything at all? It would be better to quote nothing and
> just say @Rick, then to quote something which does not have
> any context.

You snipped the bit that says [normal cobblers snipped].

>
> Every python programmer worth his *SALT* should master the
> following three text processing capabilities of Python, and
> he should know how and when to apply them (for they all have
> strengths and weaknesses):
>
>      (1) String methods: Simplistic API, but with limited
>          capabilities -- but never underestimate the
>          possibilities!
>
>      (2) Regexps: Great for pattern matching with a powerful
>          and concise syntax, but highly cryptic and unintuitive
>          for the neophyte (and sometimes even the guru! *wink*).
>
>      (3) Parsers: Great for extracting deeper meaning from text,
>          but if pattern matching is all you need, then why not
>          use (1) or (2) -- are you scared or uninformed?
>

String methods, regexes, parsers, isn't that what I've already said 
above?  Why repeat it?

>      "We can easily forgive a child who is afraid of the
>      dark; the real tragedy of life is when men are afraid of
>      the light. -- Plato
>
> IMHO, if you seek to only match patterns, then string
> methods should be your first choice, however, if the pattern
> is too difficult for string methods, then graduate to
> regexps. If you need to extract deeper meaning from
> text, by all means utilize a parser.
>

I feel humbled that a great such as yourself is again repeating what 
I've already said.

> But above all, don't fall for these "religious teachings"
> about how regexps are too difficult for mortals -- that's
> just hysteria. If you follow the outline i provided above,
> you should find Python's "text processing Nirvana".
>

My favourite things in programming all go along the lines of DRY and 
KISS, with "Although practicality beats purity" being the most important 
of the lot.  So called "religious teachings" never enter into my way of 
doing things.  For example I can't stand code which jumps through hoops 
to avoid using GOTO, whereas nothing is cleaner than (say) GOTO ERROR. 
You'll (plural) find loads of them in cPython.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Python 3 regex? Ian <hobson42@gmail.com> - 2015-01-12 19:48 +0000
  Re: Python 3 regex? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-01-12 15:47 -0800
    Re: Python 3 regex? Chris Angelico <rosuav@gmail.com> - 2015-01-13 10:52 +1100
    Re: Python 3 regex? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-13 01:54 +0000
      Re: Python 3 regex? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-01-12 18:53 -0800
        Re: Python 3 regex? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-13 05:34 +0000
          Re: Python 3 regex? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-01-13 08:01 -0800
        Re: Python 3 regex? wxjmfauth@gmail.com - 2015-01-13 11:19 -0800
          Re: Python 3 regex? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-14 14:02 +0100
            Re: Python 3 regex? alister <alister.nospam.ware@ntlworld.com> - 2015-01-14 15:11 +0000
              Re: Python 3 regex? wxjmfauth@gmail.com - 2015-01-14 10:10 -0800
            Re: Python 3 regex? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-15 11:33 +1100
              Re: Python 3 regex? wxjmfauth@gmail.com - 2015-01-14 23:03 -0800
                Re: Python 3 regex? wxjmfauth@gmail.com - 2015-01-15 00:19 -0800
              Re: Python 3 regex? wxjmfauth@gmail.com - 2015-01-15 04:49 -0800
    Re: Python 3 regex? Steven D'Aprano <steve@pearwood.info> - 2015-01-13 06:39 +0000
      Re: Python 3 regex? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-01-13 09:09 -0800
        Re: Python 3 regex? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-01-13 10:17 -0800
  Re: Python 3 regex? Steven D'Aprano <steve@pearwood.info> - 2015-01-13 04:36 +0000
    Re: Python 3 regex? alister <alister.nospam.ware@ntlworld.com> - 2015-01-13 13:23 +0000
      Re: Python 3 regex? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-01-13 15:58 +0200
    Re: Python 3 regex? Rustom Mody <rustompmody@gmail.com> - 2015-01-14 21:03 -0800
    Re: Python 3 regex? Rustom Mody <rustompmody@gmail.com> - 2015-01-14 21:08 -0800

csiph-web