Re: pattern block expression matching

2018-07-22 Thread aldi . kraja
Thank you all for thoughtful excellent updates! Aldi -- https://mail.python.org/mailman/listinfo/python-list

Re: pattern block expression matching

2018-07-21 Thread Dan Sommers
On Sat, 21 Jul 2018 17:37:00 +0100, MRAB wrote: > On 2018-07-21 15:20, aldi.kr...@gmail.com wrote: >> Hi, >> I have a long text, which tells me which files from a database were >> downloaded and which ones failed. The pattern is as follows (at the end of >> this post). Wrote a tiny program, but

Re: pattern block expression matching

2018-07-21 Thread Peter Otten
MRAB wrote: > On 2018-07-21 15:20, aldi.kr...@gmail.com wrote: >> Hi, >> I have a long text, which tells me which files from a database were >> downloaded and which ones failed. The pattern is as follows (at the end >> of this post). Wrote a tiny program, but still is raw. I want to find >> term "

Re: pattern block expression matching

2018-07-21 Thread MRAB
On 2018-07-21 15:20, aldi.kr...@gmail.com wrote: Hi, I have a long text, which tells me which files from a database were downloaded and which ones failed. The pattern is as follows (at the end of this post). Wrote a tiny program, but still is raw. I want to find term "ERROR" and go 5 lines abov

Re: pattern

2018-06-16 Thread Cameron Simpson
On 16Jun2018 11:59, Sharan Basappa wrote: This is so kind of you. Thanks for spending time to explain the code. It did help a lot. I did go back and brush up lists & dictionaries. At this point, I think, I need to go back and brush up Python from the start. So, I will do that first. Sure, sou

Re: pattern

2018-06-16 Thread Sharan Basappa
Dear Cameron, This is so kind of you. Thanks for spending time to explain the code. It did help a lot. I did go back and brush up lists & dictionaries. At this point, I think, I need to go back and brush up Python from the start. So, I will do that first. On Friday, 15 June 2018 09:12:22 UTC+5:3

Re: pattern

2018-06-14 Thread Cameron Simpson
On 14Jun2018 20:01, Sharan Basappa wrote: >Can anyone explain to me the purpose of "pattern" in the line below: > >documents.append((w, pattern['class'])) > >documents is declared as a list as follows: >documents.append((w, pattern['class'])) Not without a lot more context. Where did you find t

Re: pattern

2018-06-14 Thread Sharan Basappa
> >Can anyone explain to me the purpose of "pattern" in the line below: > > > >documents.append((w, pattern['class'])) > > > >documents is declared as a list as follows: > >documents.append((w, pattern['class'])) > > Not without a lot more context. Where did you find this code? > > Cheers, I am

Re: pattern

2018-06-14 Thread Cameron Simpson
On 13Jun2018 19:51, Sharan Basappa wrote: Can anyone explain to me the purpose of "pattern" in the line below: documents.append((w, pattern['class'])) documents is declared as a list as follows: documents.append((w, pattern['class'])) Not without a lot more context. Where did you find this c

Re: Pattern Search Regular Expression

2013-06-15 Thread Mark Lawrence
On 15/06/2013 22:03, Joshua Landau wrote: On 15 June 2013 11:18, Mark Lawrence wrote: I tend to reach for string methods rather than an RE so will something like this suit you? c:\Users\Mark\MyPython>type a.py for s in ("In the ocean", "On the ocean", "By the ocean",

Re: Pattern Search Regular Expression

2013-06-15 Thread Joshua Landau
On 15 June 2013 11:18, Mark Lawrence wrote: > I tend to reach for string methods rather than an RE so will something like > this suit you? > > c:\Users\Mark\MyPython>type a.py > for s in ("In the ocean", > "On the ocean", > "By the ocean", > "In this group", >

Re: Pattern Search Regular Expression

2013-06-15 Thread rurpy
Oops... On Saturday, June 15, 2013 12:47:18 PM UTC-6, ru...@yahoo.com wrote: > Links to the Python reference documentation are useful for people > just beginning with some aspect of Python; they are for people who > already know Python and want to look up details. That was supposed to be: Link

Re: Pattern Search Regular Expression

2013-06-15 Thread Terry Reedy
On 6/15/2013 12:28 PM, subhabangal...@gmail.com wrote: Suppose I want a regular expression that matches both "Sent from my iPhone" and "Sent from my iPod". How do I write such an expression--is the problem, "Sent from my iPod" "Sent from my iPhone" which can be written as, re.compile("Sent fro

Re: Pattern Search Regular Expression

2013-06-15 Thread subhabangalore
On Sunday, June 16, 2013 12:17:18 AM UTC+5:30, ru...@yahoo.com wrote: > On Saturday, June 15, 2013 11:54:28 AM UTC-6, subhaba...@gmail.com wrote: > > > > > Thank you for the answer. But I want to learn bit of interesting > > > regular expression forms where may I? > > > No Mark, thank you for

Re: Pattern Search Regular Expression

2013-06-15 Thread rurpy
On Saturday, June 15, 2013 11:54:28 AM UTC-6, subhaba...@gmail.com wrote: > Thank you for the answer. But I want to learn bit of interesting > regular expression forms where may I? > No Mark, thank you for your links but they were not sufficient. Links to the Python reference documentation are u

Re: Pattern Search Regular Expression

2013-06-15 Thread subhabangalore
On Saturday, June 15, 2013 3:12:55 PM UTC+5:30, subhaba...@gmail.com wrote: > Dear Group, > > > > I am trying to search the following pattern in Python. > > > > I have following strings: > > > > (i)"In the ocean" > > (ii)"On the ocean" > > (iii) "By the ocean" > > (iv) "In this grou

Re: Pattern Search Regular Expression

2013-06-15 Thread rurpy
On 06/15/2013 03:42 AM, subhabangal...@gmail.com wrote:> Dear Group, > > I am trying to search the following pattern in Python. > > I have following strings: > > (i)"In the ocean" > (ii)"On the ocean" > (iii) "By the ocean" > (iv) "In this group" > (v) "In this group" > (vi) "By the new gr

Re: Pattern Search Regular Expression

2013-06-15 Thread Mark Lawrence
On 15/06/2013 17:28, subhabangal...@gmail.com wrote: You've been pointed at several links, so what have you tried, and what, if anything, went wrong? Or do you simply not understand, in which case please say so and we'll help. I'm not trying to be awkward, it's simply known that you learn mo

Re: Pattern Search Regular Expression

2013-06-15 Thread subhabangalore
On Saturday, June 15, 2013 8:34:59 PM UTC+5:30, Mark Lawrence wrote: > On 15/06/2013 15:31, subhabangal...@gmail.com wrote: > > > > > > Dear Group, > > > > > > I know this solution but I want to have Regular Expression option. Just > > learning. > > > > > > Regards, > > > Subhabrata. > > >

Re: Pattern Search Regular Expression

2013-06-15 Thread Mark Lawrence
On 15/06/2013 15:31, subhabangal...@gmail.com wrote: Dear Group, I know this solution but I want to have Regular Expression option. Just learning. Regards, Subhabrata. Start here http://docs.python.org/2/library/re.html Would you also please read and action this, http://wiki.python.org/m

Re: Pattern Search Regular Expression

2013-06-15 Thread Andreas Perstinger
subhabangal...@gmail.com wrote: >I know this solution but I want to have Regular Expression option. >Just learning. http://mattgemmell.com/2008/12/08/what-have-you-tried/ Just spell out what you want: A word at the beginning, followed by any text, followed by a word at the end. Now look up the ba

Re: Pattern Search Regular Expression

2013-06-15 Thread subhabangalore
On Saturday, June 15, 2013 7:58:44 PM UTC+5:30, Mark Lawrence wrote: > On 15/06/2013 14:45, Denis McMahon wrote: > > > On Sat, 15 Jun 2013 13:41:21 +, Denis McMahon wrote: > > > > > >> first_and_last = [sentence.split()[i] for i in (0, -1)] middle = > > >> sentence.split()[1:-2] > > > > >

Re: Pattern Search Regular Expression

2013-06-15 Thread Mark Lawrence
On 15/06/2013 14:45, Denis McMahon wrote: On Sat, 15 Jun 2013 13:41:21 +, Denis McMahon wrote: first_and_last = [sentence.split()[i] for i in (0, -1)] middle = sentence.split()[1:-2] Bugger! That last is actually: sentence.split()[1:-1] It just looks like a two. I've a very strong se

Re: Pattern Search Regular Expression

2013-06-15 Thread Denis McMahon
On Sat, 15 Jun 2013 13:41:21 +, Denis McMahon wrote: > first_and_last = [sentence.split()[i] for i in (0, -1)] middle = > sentence.split()[1:-2] Bugger! That last is actually: sentence.split()[1:-1] It just looks like a two. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.pytho

Re: Pattern Search Regular Expression

2013-06-15 Thread Denis McMahon
On Sat, 15 Jun 2013 11:55:34 +0100, Mark Lawrence wrote: > >>> sentence = "By the new group" > >>> words = sentence.split() > >>> words[words[0],words[-1]] > Traceback (most recent call last): >File "", line 1, in > TypeError: list indices must be integers, not tuple > > So why would the

Re: Pattern Search Regular Expression

2013-06-15 Thread rusi
On Jun 15, 3:55 pm, Mark Lawrence wrote: > On 15/06/2013 11:24, Denis McMahon wrote: > > > > > > > > > > > On Sat, 15 Jun 2013 10:05:01 +, Steven D'Aprano wrote: > > >> On Sat, 15 Jun 2013 02:42:55 -0700, subhabangalore wrote: > > >>> Dear Group, > > >>> I am trying to search the following pat

Re: Pattern Search Regular Expression

2013-06-15 Thread Mark Lawrence
On 15/06/2013 11:24, Denis McMahon wrote: On Sat, 15 Jun 2013 10:05:01 +, Steven D'Aprano wrote: On Sat, 15 Jun 2013 02:42:55 -0700, subhabangalore wrote: Dear Group, I am trying to search the following pattern in Python. I have following strings: (i)"In the ocean" (ii)"On the ocean"

Re: Pattern Search Regular Expression

2013-06-15 Thread Denis McMahon
On Sat, 15 Jun 2013 10:05:01 +, Steven D'Aprano wrote: > On Sat, 15 Jun 2013 02:42:55 -0700, subhabangalore wrote: > >> Dear Group, >> >> I am trying to search the following pattern in Python. >> >> I have following strings: >> >> (i)"In the ocean" (ii)"On the ocean" (iii) "By the ocean"

Re: Pattern Search Regular Expression

2013-06-15 Thread Mark Lawrence
On 15/06/2013 10:42, subhabangal...@gmail.com wrote: Dear Group, I am trying to search the following pattern in Python. I have following strings: (i)"In the ocean" (ii)"On the ocean" (iii) "By the ocean" (iv) "In this group" (v) "In this group" (vi) "By the new group" .

Re: Pattern Search Regular Expression

2013-06-15 Thread Steven D'Aprano
On Sat, 15 Jun 2013 02:42:55 -0700, subhabangalore wrote: > Dear Group, > > I am trying to search the following pattern in Python. > > I have following strings: > > (i)"In the ocean" > (ii)"On the ocean" > (iii) "By the ocean" > (iv) "In this group" > (v) "In this group" > (vi) "By the ne

Re: Pattern-match & Replace - help required

2012-12-19 Thread MRAB
On 2012-12-19 14:11, Alexander Blinne wrote: Am 19.12.2012 14:41, schrieb AT: Thanks a million Can you recommend a good online book/tutorial on regular expr. in python? http://docs.python.org/3/howto/regex.html Another good resource is: http://www.regular-expressions.info/ -- http://mail.p

Re: Pattern-match & Replace - help required

2012-12-19 Thread Alexander Blinne
Am 19.12.2012 14:41, schrieb AT: > Thanks a million > Can you recommend a good online book/tutorial on regular expr. in python? http://docs.python.org/3/howto/regex.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Pattern-match & Replace - help required

2012-12-19 Thread AT
On Wednesday, 19 December 2012 18:16:18 UTC+5, Peter Otten wrote: > AT wrote: > > > > > I am new to python and web2py framework. Need urgent help to match a > > > pattern in an string and replace the matched text. > > > > > > I've this string (basically an sql statement): > > > stmnt = 'SE

Re: Pattern-match & Replace - help required

2012-12-19 Thread Peter Otten
AT wrote: > I am new to python and web2py framework. Need urgent help to match a > pattern in an string and replace the matched text. > > I've this string (basically an sql statement): > stmnt = 'SELECT taxpayer.id, > taxpayer.enc_name, > taxpayer.age, > taxpayer.occup

Re: Pattern-match & Replace - help required

2012-12-19 Thread AT
On Wednesday, 19 December 2012 16:27:19 UTC+5, Thomas Bach wrote: > On Wed, Dec 19, 2012 at 02:42:26AM -0800, AT wrote: > > > Hi, > > > > > > I am new to python and web2py framework. Need urgent help to match a > > > pattern in an string and replace the matched text. > > > > > > > Well,

Re: Pattern-match & Replace - help required

2012-12-19 Thread Thomas Bach
On Wed, Dec 19, 2012 at 02:42:26AM -0800, AT wrote: > Hi, > > I am new to python and web2py framework. Need urgent help to match a > pattern in an string and replace the matched text. > Well, what about str.replace then? >>> 'egg, ham, tomato'.replace('ham', 'spam, ham, spam') 'egg, spam, ham,

Re: Pattern-match & Replace - help required

2012-12-19 Thread Steven D'Aprano
On Wed, 19 Dec 2012 03:01:32 -0800, AT wrote: > I just wanted to change taxpayer.enc_name in stmnt to > decrypt(taxpayer.enc_name) > > hope it clarifies? Maybe. Does this help? lunch = "Bread, ham, cheese and tomato." # replace ham with spam offset = lunch.find('ham') if offset != -1: lunch

Re: Pattern-match & Replace - help required

2012-12-19 Thread AT
On Wednesday, 19 December 2012 15:51:22 UTC+5, Steven D'Aprano wrote: > On Wed, 19 Dec 2012 02:42:26 -0800, AT wrote: > > > > > Hi, > > > > > > I am new to python and web2py framework. Need urgent help to match a > > > pattern in an string and replace the matched text. > > > > > > I've

Re: Pattern-match & Replace - help required

2012-12-19 Thread Steven D'Aprano
On Wed, 19 Dec 2012 02:42:26 -0800, AT wrote: > Hi, > > I am new to python and web2py framework. Need urgent help to match a > pattern in an string and replace the matched text. > > I've this string (basically an sql statement): > > stmnt = 'SELECT taxpayer.id, > taxpayer.enc_name, >

Re: pattern matching

2011-02-24 Thread Jon Clements
On Feb 24, 2:11 am, monkeys paw wrote: > if I have a string such as '01/12/2011' and i want > to reformat it as '20110112', how do i pull out the components > of the string and reformat them into a DDMM format? > > I have: > > import re > > test = re.compile('\d\d\/') > f = open('test.html')  

Re: pattern matching

2011-02-24 Thread John S
On Feb 23, 9:11 pm, monkeys paw wrote: > if I have a string such as '01/12/2011' and i want > to reformat it as '20110112', how do i pull out the components > of the string and reformat them into a DDMM format? > > I have: > > import re > > test = re.compile('\d\d\/') > f = open('test.html')  

Re: pattern matching

2011-02-23 Thread Dr Vangel
if I have a string such as '01/12/2011' and i want to reformat it as '20110112', how do i pull out the components of the string and reformat them into a DDMM format? I have: import re test = re.compile('dd/') f = open('test.html') # This file contains the html dates for line in f: if

Re: pattern matching

2011-02-23 Thread Roy Smith
In article , Chris Rebert wrote: > regex = compile("(\d\d)/(\d\d)/(\d{4})") I would probably write that as either r"(\d{2})/(\d{2})/(\d{4})" or (somewhat less likely) r"(\d\d)/(\d\d)/(\d\d\d\d)" Keeping to one consistent style makes it a little easier to read. Also, don't forget the leadi

Re: pattern matching

2011-02-23 Thread Chris Rebert
On Wed, Feb 23, 2011 at 6:37 PM, Steven D'Aprano wrote: > On Wed, 23 Feb 2011 21:11:53 -0500, monkeys paw wrote: >> if I have a string such as '01/12/2011' and i want to reformat >> it as '20110112', how do i pull out the components of the string and >> reformat them into a DDMM format? > > da

Re: pattern matching

2011-02-23 Thread Steven D'Aprano
On Wed, 23 Feb 2011 21:11:53 -0500, monkeys paw wrote: > if I have a string such as '01/12/2011' and i want to reformat > it as '20110112', how do i pull out the components of the string and > reformat them into a DDMM format? data = '01/12/2011' # Throw away tags. data = data[4:-5] # Separat

Re: pattern matching

2011-02-23 Thread Roy Smith
In article , monkeys paw wrote: > if I have a string such as '01/12/2011' and i want > to reformat it as '20110112', how do i pull out the components > of the string and reformat them into a DDMM format? > > I have: > > import re > > test = re.compile('\d\d\/') > f = open('test.html') #

Re: pattern matching with multiple lists

2010-07-16 Thread Tim Chase
On 07/16/2010 02:20 PM, Chad Kellerman wrote: Greetings, I have some code that I wrote and know there is a better way to write it. I wonder if anyone could point me in the right direction on making this 'cleaner'. I have two lists: liveHostList = [ app11, app12, web11, web12, hos

Re: pattern matching with multiple lists

2010-07-16 Thread MRAB
Chad Kellerman wrote: Greetings, I have some code that I wrote and know there is a better way to write it. I wonder if anyone could point me in the right direction on making this 'cleaner'. I have two lists: liveHostList = [ app11, app12, web11, web12, host11 ]

Re: Defining re pattern for matching list of numbers

2009-11-07 Thread Steven D'Aprano
On Fri, 06 Nov 2009 10:16:31 -0800, Chris Rebert wrote: > Your format seems so simple I have to ask why you're using regexes in > the first place. Raymond Hettinger has described some computing techniques as "code prions" -- programming advice or techniques which are sometimes useful but often

Re: ask for a RE pattern to match TABLE in html

2008-07-01 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, Jonathan Gardner <[EMAIL PROTECTED]> wrote: > On Jun 27, 10:32 am, "David C. Ullrich" <[EMAIL PROTECTED]> wrote: > > (ii) The regexes in languages like Python and Perl include > > features that are not part of the formal CS notion of > > "regular expression". Do t

Re: ask for a RE pattern to match TABLE in html

2008-06-30 Thread Jonathan Gardner
On Jun 27, 10:32 am, "David C. Ullrich" <[EMAIL PROTECTED]> wrote: > (ii) The regexes in languages like Python and Perl include > features that are not part of the formal CS notion of > "regular expression". Do they include something that > does allow parsing nested delimiters properly? > In perl,

Re: ask for a RE pattern to match TABLE in html

2008-06-30 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, Dan <[EMAIL PROTECTED]> wrote: > On Jun 27, 1:32 pm, "David C. Ullrich" <[EMAIL PROTECTED]> wrote: > > In article > > <[EMAIL PROTECTED]>, > > Jonathan Gardner <[EMAIL PROTECTED]> wrote: > > > > > On Jun 26, 3:22 pm, MRAB <[EMAIL PROTECTED]> wrote: > > > > Try so

Re: ask for a RE pattern to match TABLE in html

2008-06-27 Thread Dan
On Jun 27, 1:32 pm, "David C. Ullrich" <[EMAIL PROTECTED]> wrote: > In article > <[EMAIL PROTECTED]>, > Jonathan Gardner <[EMAIL PROTECTED]> wrote: > > > On Jun 26, 3:22 pm, MRAB <[EMAIL PROTECTED]> wrote: > > > Try something like: > > > > re.compile(r'.*?', re.DOTALL) > > > So you would pick up s

Re: ask for a RE pattern to match TABLE in html

2008-06-27 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, Jonathan Gardner <[EMAIL PROTECTED]> wrote: > On Jun 26, 3:22 pm, MRAB <[EMAIL PROTECTED]> wrote: > > Try something like: > > > > re.compile(r'.*?', re.DOTALL) > > So you would pick up strings like "foo td>"? I doubt that is what oyster wants. I asked a question

Re: ask for a RE pattern to match TABLE in html

2008-06-26 Thread Jonathan Gardner
On Jun 26, 3:22 pm, MRAB <[EMAIL PROTECTED]> wrote: > Try something like: > > re.compile(r'.*?', re.DOTALL) So you would pick up strings like "foo"? I doubt that is what oyster wants. -- http://mail.python.org/mailman/listinfo/python-list

Re: ask for a RE pattern to match TABLE in html

2008-06-26 Thread Jonathan Gardner
On Jun 26, 11:07 am, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-06-26, Stefan Behnel <[EMAIL PROTECTED]> wrote: > > > > Why not use an HTML parser instead? > > > > Stating it differently: in order to correctly recognize HTML > tags, you must use an HTML parser.  Trying to write an HTML > pa

Re: ask for a RE pattern to match TABLE in html

2008-06-26 Thread MRAB
no TABLE tag between a TABLE, for example > > > something with out table tag > > > what is the RE pattern? thanks > > > > the following is not right > > > [^table]*? > > > The construct [abc] does not match a whole word but only one char, so   >

Re: ask for a RE pattern to match TABLE in html

2008-06-26 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, Cédric Lucantis <[EMAIL PROTECTED]> wrote: > Le Thursday 26 June 2008 15:53:06 oyster, vous avez écrit : > > that is, there is no TABLE tag between a TABLE, for example > > something with out table tag > > what is the RE pattern

Re: ask for a RE pattern to match TABLE in html

2008-06-26 Thread Grant Edwards
On 2008-06-26, Stefan Behnel <[EMAIL PROTECTED]> wrote: > oyster wrote: >> that is, there is no TABLE tag between a TABLE, for example >> something with out table tag >> what is the RE pattern? thanks >> >> the following is not right >> [^table]*? >

Re: ask for a RE pattern to match TABLE in html

2008-06-26 Thread Stefan Behnel
oyster wrote: > that is, there is no TABLE tag between a TABLE, for example > something with out table tag > what is the RE pattern? thanks > > the following is not right > [^table]*? Why not use an HTML parser instead? Try lxml.html. http://codespeak.net/lxml/ Stefan -- http

Re: ask for a RE pattern to match TABLE in html

2008-06-26 Thread Cédric Lucantis
Le Thursday 26 June 2008 15:53:06 oyster, vous avez écrit : > that is, there is no TABLE tag between a TABLE, for example > something with out table tag > what is the RE pattern? thanks > > the following is not right > [^table]*? The construct [abc] does not match a whole word

ask for a RE pattern to match TABLE in html

2008-06-26 Thread oyster
that is, there is no TABLE tag between a TABLE, for example something with out table tag what is the RE pattern? thanks the following is not right [^table]*? -- http://mail.python.org/mailman/listinfo/python-list

Re: Pattern Matching Over Python Lists

2008-06-22 Thread eliben
> Fair enough. To help you understand the method I used, I'll give you > this hint. It's true that regex on works on strings. However, is there > any way to convert arbitrarily complex data structures to string > representations? You don't need to be an experienced Python user to > answer to this ;

Re: Pattern Matching Over Python Lists

2008-06-22 Thread Chris
On Jun 19, 9:03 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jun 20, 10:45 am, Chris <[EMAIL PROTECTED]> wrote: > > > On Jun 17, 1:09 pm, [EMAIL PROTECTED] wrote: > > > > Kirk Strauser: > > > > > Hint: recursion. Your general algorithm will be something like: > > > > Another solution is to use

Re: Pattern Matching Over Python Lists

2008-06-20 Thread MRAB
On Jun 20, 1:45 am, Chris <[EMAIL PROTECTED]> wrote: > On Jun 17, 1:09 pm, [EMAIL PROTECTED] wrote: > > > Kirk Strauser: > > > > Hint: recursion.  Your general algorithm will be something like: > > > Another solution is to use a better (different) language, that has > > built-in pattern matching, o

Re: Pattern Matching Over Python Lists

2008-06-19 Thread Paddy
On Jun 20, 1:44 am, Chris <[EMAIL PROTECTED]> wrote: > Thanks for your help. Those weren't quite what I was looking for, but > I ended up figuring it out on my own. Turns out you can actually > search nested Python lists using simple regular expressions. Strange? How do you match nested '[' ... ']

Re: Pattern Matching Over Python Lists

2008-06-19 Thread John Machin
On Jun 20, 10:45 am, Chris <[EMAIL PROTECTED]> wrote: > On Jun 17, 1:09 pm, [EMAIL PROTECTED] wrote: > > > Kirk Strauser: > > > > Hint: recursion. Your general algorithm will be something like: > > > Another solution is to use a better (different) language, that has > > built-in pattern matching,

Re: Pattern Matching Over Python Lists

2008-06-19 Thread Chris
On Jun 17, 1:09 pm, [EMAIL PROTECTED] wrote: > Kirk Strauser: > > > Hint: recursion. Your general algorithm will be something like: > > Another solution is to use a better (different) language, that has > built-in pattern matching, or allows to create one. > > Bye, > bearophile Btw, Python's stdl

Re: Pattern Matching Over Python Lists

2008-06-19 Thread Chris
Thanks for your help. Those weren't quite what I was looking for, but I ended up figuring it out on my own. Turns out you can actually search nested Python lists using simple regular expressions. -- http://mail.python.org/mailman/listinfo/python-list

Re: Pattern Matching Over Python Lists

2008-06-17 Thread bearophileHUGS
Kirk Strauser: > Hint: recursion. Your general algorithm will be something like: Another solution is to use a better (different) language, that has built-in pattern matching, or allows to create one. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Pattern Matching Over Python Lists

2008-06-17 Thread Kirk Strauser
At 2008-06-17T05:55:52Z, Chris <[EMAIL PROTECTED]> writes: > Is anyone aware of any prior work done with searching or matching a > pattern over nested Python lists? I have this problem where I have a > list like: > > [1, 2, [1, 2, [1, 7], 9, 9], 10] > > and I'd like to search for the pattern [1, 2

Re: Tips Re Pattern Matching / REGEX

2008-03-27 Thread Miki
Hello, > I have a large text file (1GB or so) with structure similar to the > html example below. > > I have to extract content (text between div and tr tags) from this > file and put it into a spreadsheet or a database - given my limited > python knowledge I was going to try to do this with regex

Tips Re Pattern Matching / REGEX

2008-03-27 Thread egonslokar
Hello Python Community, I have a large text file (1GB or so) with structure similar to the html example below. I have to extract content (text between div and tr tags) from this file and put it into a spreadsheet or a database - given my limited python knowledge I was going to try to do this with

Re: pattern combinations

2007-09-17 Thread dohertywa
On Sep 17, 3:11 pm, "Shawn Milochik" <[EMAIL PROTECTED]> wrote: > On 9/17/07, dorje tarap <[EMAIL PROTECTED]> wrote: > > > > > Hi all, > > > Given some patterns such as "...t...s." I need to make all possible > > combinations given a separate list for each position. The length of the > > pattern i

Re: pattern combinations

2007-09-17 Thread Shawn Milochik
On 9/17/07, dorje tarap <[EMAIL PROTECTED]> wrote: > Hi all, > > Given some patterns such as "...t...s." I need to make all possible > combinations given a separate list for each position. The length of the > pattern is fixed to 9, so thankfully that reduces a bit of the complexity. > > For examp

Re: Pattern for error checking easiest-first?

2007-08-20 Thread Gabriel Genellina
On 20 ago, 18:01, [EMAIL PROTECTED] wrote: > The problem is that code like this does error checking backwards. A > call to NetworkedThing.changeMe will first do a slow error check and > then a fast one. Obviously there are various ways to get around this - > either have the subclass explicitly ask

Re: pattern match !

2007-07-15 Thread Asun Friere
On Jul 11, 9:29 pm, Helmut Jarausch <[EMAIL PROTECTED]> wrote: > import re > P=re.compile(r'(\w+(?:[-.]\d+)+)-RHEL3-Linux\.RPM') > S="hpsmh-1.1.1.2-0-RHEL3-Linux.RPM" > PO= P.match(S) > if PO : >print PO.group(1) Isn't a regexp overkill here when this will do: head = filename[:filename.index

Re: pattern match !

2007-07-14 Thread Jay Loden
[EMAIL PROTECTED] wrote: >> A slightly more generic match in case your package names turn out to be less >> consistent than given in the test cases: >> >> #!/usr/bin/python >> >> import re >> pattern = re.compile(r'(\w+?-(\d+[\.-])+\d+?)-\D+.*RPM&#x

Re: pattern match !

2007-07-11 Thread Jay Loden
names turn out to be less consistent than given in the test cases: #!/usr/bin/python import re pattern = re.compile(r'(\w+?-(\d+[\.-])+\d+?)-\D+.*RPM') pkgnames = ["hpsmh-1.1.1.2-0-RHEL3-Linux.RPM", "hpsmh-1.1.1.2-RHEL3-Linux.RPM"] for pkg in pkgnames: matchObj = pa

Re: pattern match !

2007-07-11 Thread Helmut Jarausch
[EMAIL PROTECTED] wrote: > Extract the application name with version from an RPM string like > hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, i require to extract hpsmh-1.1.1.2-0 > from above string. Sometimes the RPM string may be hpsmh-1.1.1.2-RHEL3- > Linux.RPM. > Have a try with import re P=re.compile(r'(

Re: pattern match !

2007-07-10 Thread Asun Friere
On Jul 11, 1:40 pm, [EMAIL PROTECTED] wrote: > Extract the application name with version from an RPM string like > hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, i require to extract hpsmh-1.1.1.2-0 > from above string. Sometimes the RPM string may be hpsmh-1.1.1.2-RHEL3- > Linux.RPM. Now that list-like splicin

Re: pattern match !

2007-07-10 Thread Steven D'Aprano
On Wed, 11 Jul 2007 03:40:06 +, hari.siri74 wrote: > Extract the application name with version from an RPM string like > hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, i require to extract hpsmh-1.1.1.2-0 > from above string. Sometimes the RPM string may be hpsmh-1.1.1.2-RHEL3- > Linux.RPM. Thank you for s

Re: Pattern Classification Frameworks?

2007-06-12 Thread Miki
Hello Evan, > What frameworks are there available for doing pattern classification? > ... Two Bayesian classifiers are SpamBayes (http://spambayes.sf.net) and Reverend Thomas (http://www.divmod.org/projects/reverend). IMO the latter will be easier to play with. > Also, as a sidenote, are there an

Re: Pattern Classification Frameworks?

2007-06-12 Thread Evan Klitzke
On 6/12/07, Steven Bethard <[EMAIL PROTECTED]> wrote: > In fact, a wide variety of classifiers are used in text classification, > including Bayesian approaches, support vector machines, conditional > random fields, etc. > > > Are there any other frameworks I should be aware of? > > I have used (but

Re: Pattern Classification Frameworks?

2007-06-12 Thread Steven Bethard
Evan Klitzke wrote: > What frameworks are there available for doing pattern classification? > I'm generally interested in the problem of mapping some sort of input > to one or more categories. For example, I want to be able to solve > problems like taking text and applying one or more tags to it li

Re: Pattern Classification Frameworks?

2007-06-12 Thread Diez B. Roggisch
Evan Klitzke wrote: > Hi all, > > What frameworks are there available for doing pattern classification? > I'm generally interested in the problem of mapping some sort of input > to one or more categories. For example, I want to be able to solve > problems like taking text and applying one or more

Re: pattern search

2007-03-29 Thread Fabian Braennstroem
Hi Paul, Paul McGuire schrieb am 03/27/2007 07:19 PM: > On Mar 27, 3:13 pm, Fabian Braennstroem <[EMAIL PROTECTED]> wrote: >> Hi to all, >> >> Wojciech Mu?a schrieb am 03/27/2007 03:34 PM: >> >>> Fabian Braennstroem wrote: Now, I would like to improve it by searching for different 'real'

Re: pattern search

2007-03-28 Thread Fabian Braennstroem
Hi, Gabriel Genellina schrieb am 03/27/2007 10:09 PM: > En Tue, 27 Mar 2007 18:42:15 -0300, Diez B. Roggisch <[EMAIL PROTECTED]> > escribió: > >> Paul McGuire schrieb: >>> On Mar 27, 10:18 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: Fabian Braennstroem wrote: > wh

Re: pattern search

2007-03-27 Thread Gabriel Genellina
En Tue, 27 Mar 2007 18:42:15 -0300, Diez B. Roggisch <[EMAIL PROTECTED]> escribió: > Paul McGuire schrieb: >> On Mar 27, 10:18 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >>> Fabian Braennstroem wrote: while iter: value = model.get_value(iter,

Re: pattern search

2007-03-27 Thread Diez B. Roggisch
Paul McGuire schrieb: > On Mar 27, 10:18 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> Fabian Braennstroem wrote: >>> Hi, >>> I wrote a small gtk file manager, which works pretty well. Until >>> now, I am able to select different file (treeview entries) just by >>> extension (done with 'ends

Re: pattern search

2007-03-27 Thread Paul McGuire
On Mar 27, 3:13 pm, Fabian Braennstroem <[EMAIL PROTECTED]> wrote: > Hi to all, > > Wojciech Mu?a schrieb am 03/27/2007 03:34 PM: > > > Fabian Braennstroem wrote: > >> Now, I would like to improve it by searching for different 'real' > >> patterns just like using 'ls' in bash. E.g. the entry > >> '

Re: pattern search

2007-03-27 Thread Paul McGuire
On Mar 27, 10:18 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Fabian Braennstroem wrote: > > Hi, > > > I wrote a small gtk file manager, which works pretty well. Until > > now, I am able to select different file (treeview entries) just by > > extension (done with 'endswith'). See the little

Re: pattern search

2007-03-27 Thread Fabian Braennstroem
Hi to all, Wojciech Mu?a schrieb am 03/27/2007 03:34 PM: > Fabian Braennstroem wrote: >> Now, I would like to improve it by searching for different 'real' >> patterns just like using 'ls' in bash. E.g. the entry >> 'car*.pdf' should select all pdf files with a beginning 'car'. >> Does anyone have

Re: pattern search

2007-03-27 Thread Wojciech Muła
Fabian Braennstroem wrote: > Now, I would like to improve it by searching for different 'real' > patterns just like using 'ls' in bash. E.g. the entry > 'car*.pdf' should select all pdf files with a beginning 'car'. > Does anyone have an idea, how to do it? Use module glob. -- http://mail.python.

Re: pattern search

2007-03-27 Thread Diez B. Roggisch
Fabian Braennstroem wrote: > Hi, > > I wrote a small gtk file manager, which works pretty well. Until > now, I am able to select different file (treeview entries) just by > extension (done with 'endswith'). See the little part below: > > self.pathlist1=[ ] > self.

Re: Pattern for foo tool <-> API <-> shell|GUI

2007-03-26 Thread Anastasios Hatzis
On Sunday 25 March 2007 16:44, Steven Bethard wrote: > Anastasios Hatzis wrote: > > I'm working on a tool which is totally command-line based and consisting > > of multiple scripts. The user can execute a Python script in the shell, > > this script does some basic verification before delegating a c

Re: Pattern for foo tool <-> API <-> shell|GUI

2007-03-25 Thread Steven Bethard
Anastasios Hatzis wrote: > I'm working on a tool which is totally command-line based and consisting of > multiple scripts. The user can execute a Python script in the shell, this > script does some basic verification before delegating a call into my tool's > package and depending on some argumen

Re: Pattern for foo tool <-> API <-> shell|GUI

2007-03-24 Thread Anastasios Hatzis
On Saturday 24 March 2007 18:55, [EMAIL PROTECTED] wrote: > On Mar 24, 10:31 am, Anastasios Hatzis <[EMAIL PROTECTED]> wrote: > > I'm looking for a pattern where different client implementations can use > > the same commands of some fictive tool ("foo") by accessing some kind of > > API. Actually I

Re: Pattern for foo tool <-> API <-> shell|GUI

2007-03-24 Thread kyosohma
On Mar 24, 10:31 am, Anastasios Hatzis <[EMAIL PROTECTED]> wrote: > I'm looking for a pattern where different client implementations can use the > same commands of some fictive tool ("foo") by accessing some kind of API. > Actually I have the need for such pattern for my own tool > (http://openswar

Re: pattern matching

2007-03-01 Thread Diez B. Roggisch
azrael wrote: > can someone give me good links for pattern matching in images using > python There is a python-binding available for the OpenCV library, a collection of state-of-the-art CV algorithms. And it comes with a free manual Diez -- http://mail.python.org/mailman/listinfo/python-li

  1   2   >