Re: Twisted: 1 thread in the reactor pattern

2009-09-24 Thread jacopo
On Sep 23, 5:57 pm, exar...@twistedmatrix.com wrote: > On 06:08 am, jacopo.pe...@gmail.com wrote: > > >I am diving into Twisted and Perspective Broker (PB) in particular and > >I would like to understand more about what happens behind the > >curtains. > >Say I have a client and a server on two diff

Re: Twisted: 1 thread in the reactor pattern

2009-09-23 Thread exarkun
On 06:08 am, jacopo.pe...@gmail.com wrote: I am diving into Twisted and Perspective Broker (PB) in particular and I would like to understand more about what happens behind the curtains. Say I have a client and a server on two different machines, the server gets callRemote() 19s in an asynchronous

Twisted: 1 thread in the reactor pattern

2009-09-22 Thread jacopo
them in a queue? To me it looks like there should be at least 2 processes, one for the reactor and on for the rest. In the documentation they keep stressing how one of the peculiarity of the reactor pattern is the single thread, but I can not figure out how. Any suggestion would be welcome. For the

Re: reply to OT diversion (was: What is the best method to match a pattern in set of lines

2009-06-24 Thread Ross Ridge
a...@pythoncraft.com (Aahz) writes: > Guess what? Prior to DejaNews, discussions on Usenet *were* ephemeral, > and it all worked. Not really, Usenet was archived before DejaNews arrived on the scene. I can find plenty of my posts from before then. Regardless, Usenet works better now that searcha

Re: reply to OT diversion (was: What is the best method to match a pattern in set of lines

2009-06-23 Thread Aahz
In article <024d7a38$0$20654$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: >Dennis Lee Bieber wrote: >> On Sat, 20 Jun 2009 13:47:24 -0700 (PDT), Bearophile >> declaimed the following in >> gmane.comp.python.general: >>> >>> Dennis Lee Bieber, may I ask why most or all your posts are set t

Re: reply to OT diversion (was: What is the best method to match a pattern in set of lines

2009-06-20 Thread Steven D'Aprano
Dennis Lee Bieber wrote: > On Sat, 20 Jun 2009 13:47:24 -0700 (PDT), Bearophile > declaimed the following in > gmane.comp.python.general: > >> This is a small OT post, sorry. >> >> Dennis Lee Bieber, may I ask why most or all your posts are set to "No- >> Archive"? >> > Taking into account som

Re: What is the best method to match a pattern in set of lines

2009-06-20 Thread Bearophile
This is a small OT post, sorry. Dennis Lee Bieber, may I ask why most or all your posts are set to "No- Archive"? > HTTP://www.bestiaria.com/ I think there are other furries beside you around here. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: What is the best method to match a pattern in set of lines

2009-06-20 Thread Lie Ryan
Dennis Lee Bieber wrote: > On Fri, 19 Jun 2009 17:52:05 -0700 (PDT), Terminator > declaimed the following in > gmane.comp.python.general: > >> Hello, >> My requierment is to get the "Stick Tag" value from the below o/p and >> based on tag take different actions. What is the best way to implement

What is the best method to match a pattern in set of lines

2009-06-19 Thread Terminator
Hello, My requierment is to get the "Stick Tag" value from the below o/p and based on tag take different actions. What is the best way to implement it. I am new to Python, so appreciate any input. Command o/p: === File: Packet.tcl

Re: python list pattern matching?

2009-05-29 Thread Terry Reedy
Peter Otten wrote: Terry Reedy wrote: >>> a,b,*rest = list(range(10)) The list() call is superfluous. Agreed, even in Py3 when range() returns a range object rather than a list. -- http://mail.python.org/mailman/listinfo/python-list

Re: python list pattern matching?

2009-05-29 Thread Chris Rebert
On Thu, May 28, 2009 at 3:57 PM, Terry Reedy wrote: > guthrie wrote: >> >> I want to do a functional like pattern match to get teh first two >> elements, and then the rest of an array return value. >> >> For example, assume that perms(x) returns a list of

Re: python list pattern matching?

2009-05-28 Thread Peter Otten
Terry Reedy wrote: > >>> a,b,*rest = list(range(10)) The list() call is superfluous. -- http://mail.python.org/mailman/listinfo/python-list

Re: python list pattern matching?

2009-05-28 Thread guthrie
Many thanks to all; perfect solution! -- http://mail.python.org/mailman/listinfo/python-list

Re: python list pattern matching?

2009-05-28 Thread Steven D'Aprano
On Thu, 28 May 2009 18:57:42 -0400, Terry Reedy wrote: > >>> a,b,*rest = list(range(10)) That fails in Python 2.5 and 2.6. >>> a,b,*rest = list(range(10)) File "", line 1 a,b,*rest = list(range(10)) ^ SyntaxError: invalid syntax -- Steven -- http://mail.python.org/mailman/li

Re: python list pattern matching?

2009-05-28 Thread bearophileHUGS
Terry Reedy: >  >>> a,b,*rest = list(range(10)) >  >>> a,b,rest > (0, 1, [2, 3, 4, 5, 6, 7, 8, 9]) >  >>> a,*rest,b = 'abcdefgh' >  >>> a,rest,b > ('a', ['b', 'c', 'd', 'e', 'f', 'g'], 'h') For the next few years I generally suggest to specify the Python version too (if it's 2.x or 3.x). This is P

Re: python list pattern matching?

2009-05-28 Thread Mensanator
On May 28, 5:43 pm, guthrie wrote: > I want to do a functional like pattern match to get teh first two > elements, and then the rest of an array return value. > > For example, assume that perms(x) returns a list of values, and I want > to do this: >     seq=perms(x) > >

Re: python list pattern matching?

2009-05-28 Thread Terry Reedy
guthrie wrote: I want to do a functional like pattern match to get teh first two elements, and then the rest of an array return value. For example, assume that perms(x) returns a list of values, and I want to do this: seq=perms(x) a = seq[0] b = seq[1] rest = seq[2:] Of course

python list pattern matching?

2009-05-28 Thread guthrie
I want to do a functional like pattern match to get teh first two elements, and then the rest of an array return value. For example, assume that perms(x) returns a list of values, and I want to do this: seq=perms(x) a = seq[0] b = seq[1] rest = seq[2:] Of course I can shorten to

Re: looking for a pattern to code logic shared by gui/cli

2009-04-22 Thread norseman
): for root, dirs, files in os.walk(src_dir): for file in files: # feedback for the CLI LOG.info("scanning %s %s", root, file) # check for file pattern here if os.path.exists(file2): # feedback f

Re: looking for a pattern to code logic shared by gui/cli

2009-04-16 Thread MRAB
(src_dir): for file in files: # feedback for the CLI LOG.info("scanning %s %s", root, file) # check for file pattern here if os.path.exists(file2): # feedback for the CLI LOG.info("f

Re: looking for a pattern to code logic shared by gui/cli

2009-04-16 Thread Chris Rebert
  LOG = logging.getLogger() > >   def find_files(src_dir): >       for root, dirs, files in os.walk(src_dir): >           for file in files: >               # feedback for the CLI >               LOG.info("scanning %s %s", root, file) >               # check for file patter

looking for a pattern to code logic shared by gui/cli

2009-04-16 Thread Andreas Balogh
in files: # feedback for the CLI LOG.info("scanning %s %s", root, file) # check for file pattern here if os.path.exists(file2): # feedback for the CLI LOG.info("f

Re: User or UserManager ? Problems of Observer Pattern

2009-04-04 Thread 一首诗
Thanks for your advice. I studied python from the tutorial and the library manual, and I think I am familiar enough with Python's grammar and API. That's why I never thought I need to read a book of Python. But if "Programming Python" also explains OO, I would be happy to read it. In fact, I am

Re: User or UserManager ? Problems of Observer Pattern

2009-04-03 Thread Michele Simionato
On Apr 3, 7:34 pm, 一首诗 wrote: > # > # Choice 2 > # > > class UserManager: > > users = [] > > @classmethod > def delUser(cls, user): > cls.users.remove(user) > > RoleManager.onUserDel(user) > > class RoleManager: > > roles = [] > >

User or UserManager ? Problems of Observer Pattern

2009-04-03 Thread 一首诗
_del_funcs = [] roles = [] def del(self): user_dict.pop(self.name) for f in self.on_del_funcs: f(self) # Using Observer Pattern to notify this user is deleted. def addUserDelListener(self, on_del_func): on_del_funcs.append(on_del_funcs) def delUserD

Concrete Factory Pattern syntax?

2009-03-19 Thread R. David Murray
Austin Schutz wrote: > > I have a fairly simple bit of code, something like: > > # This should be importing the subclasses somehow, so that the factory > # can make them. > # import Parser.One > # import Parser.Two > # or.. from Parser import *? > class Parser(): >def parse: > 'Impleme

Re: Concrete Factory Pattern syntax?

2009-03-19 Thread Benjamin Kaplan
On Thu, Mar 19, 2009 at 6:52 PM, Austin Schutz wrote: > > I have a fairly simple bit of code, something like: > > # This should be importing the subclasses somehow, so that the factory > # can make them. > # import Parser.One > # import Parser.Two > # or.. from Parser import *? > class Parser():

Concrete Factory Pattern syntax?

2009-03-19 Thread Austin Schutz
I have a fairly simple bit of code, something like: # This should be importing the subclasses somehow, so that the factory # can make them. # import Parser.One # import Parser.Two # or.. from Parser import *? class Parser(): def parse: 'Implemented only in subclass' def make_parser

Re: creating a pattern using a previous match and a count of the number of '('s in it

2009-01-27 Thread MRAB
upto_1st_closed_parenth[i].count('(') #expand the pattern to get all of the prototype #ie upto the last closed parenthesis #saying something like pattern = re.compile(\ 'match_upto_1st_closed_parenth[i]+\

creating a pattern using a previous match and a count of the number of '('s in it

2009-01-27 Thread me
ompile('\w+::\w+\([^)]*\)') match_upto_1st_closed_parenth= re.findall(pattern_upto_1st_closed_parenth,txt) num_of_protos = len(match_upto_1st_closed_parenth) for i in range (0,num_of_protos-1): num_of_open_parenths = match_upto_1st_closed_parenth[i].count('(') #expand the

Re: change only the nth occurrence of a pattern in a string

2009-01-14 Thread MRAB
Antoon Pardon wrote: > On 2008-12-31, TP wrote: >> Hi everybody, >> >> I would like to change only the nth occurence of a pattern in a string. The >> problem with "replace" method of strings, and "re.sub" is that we can only >> define t

Re: change only the nth occurrence of a pattern in a string

2009-01-12 Thread Antoon Pardon
On 2008-12-31, TP wrote: > Hi everybody, > > I would like to change only the nth occurence of a pattern in a string. The > problem with "replace" method of strings, and "re.sub" is that we can only > define the number of occurrences to change from the first on

Re: change only the nth occurrence of a pattern in a string

2008-12-31 Thread Tim Chase
I would like to change only the nth occurence of a pattern in a string. The problem with "replace" method of strings, and "re.sub" is that we can only define the number of occurrences to change from the first one. v="coucou" v.replace("o","i&q

Re: change only the nth occurrence of a pattern in a string

2008-12-31 Thread Steven D'Aprano
On Wed, 31 Dec 2008 15:40:32 +0100, TP wrote: > Hi everybody, > > I would like to change only the nth occurence of a pattern in a string. > The problem with "replace" method of strings, and "re.sub" is that we > can only define the number of occurrences to c

Re: change only the nth occurrence of a pattern in a string

2008-12-31 Thread Roy Smith
In article <0scs26-7a5@rama.fbx.proxad.net>, TP wrote: > Hi everybody, > > I would like to change only the nth occurence of a pattern in a string. It's a little ugly, but the following looks like it works. The gist is to split the string on your pattern, then re-j

change only the nth occurrence of a pattern in a string

2008-12-31 Thread TP
Hi everybody, I would like to change only the nth occurence of a pattern in a string. The problem with "replace" method of strings, and "re.sub" is that we can only define the number of occurrences to change from the first one. >>> v="coucou" >>

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Gerard flanagan
Slaunger wrote: Hi Gerard, This definitely looks like a path to walk along, and I think your code does the trick, although I have to play a little around with the groupby method, of which I had no prior knowledge. I think I will write some unit test cases to stress test you concept (on Monday, wh

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Gerard flanagan
Anton Vredegoor wrote: On Fri, 21 Nov 2008 18:10:02 +0100 Gerard flanagan <[EMAIL PROTECTED]> wrote: data = ''' 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 3 0 3 3 0 3 3 0 10 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 3 0 3 3 0 3 3 0 10 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Paul McGuire
So I think you just need to find the first two complete sequences of 1,6,10 and 0,3,9, remove any repetitions and then you're done. data = ''' 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 7 3 0 3 3 0 3 3 0 10 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 10 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Slaunger
On 21 Nov., 18:10, Gerard flanagan <[EMAIL PROTECTED]> wrote: > Slaunger wrote: > > Hi all, > > > I am a Python novice, and I have run into a problem in a project I am > > working on, which boils down to identifying the patterns in a sequence > > of integers, for example > > > 1 6 6 1 6 6 1 6

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Slaunger
On 21 Nov., 23:36, Mensanator <[EMAIL PROTECTED]> wrote: > Your rules appear to be incomplete and inconsistent. OK. Let me try to clarify then... > > 3. Pattern A only consists of the numbers 0, 3, and 9. 3, 3 is always > > followed by 0 > > But does a 3 always follow a

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Slaunger
> > > I am pretty sure I can figure out how to do that, but I would like to > > have some guidance on the most pythonic approach to this. > > Then it would be a good starting point to write some code. Then you > could post it and ask how it can be made more 'pythonic'. > That is actually a good poi

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Anton Vredegoor
On Fri, 21 Nov 2008 18:10:02 +0100 Gerard flanagan <[EMAIL PROTECTED]> wrote: > data = ''' > 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 3 0 3 3 0 3 3 0 10 6 6 > 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 3 0 3 3 0 3 3 0 10 6 6 > 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 3 0 3 3 0 3 3 0 1

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Mensanator
e incomplete and inconsistent. > > The rules for the sequence is: > 1. The sequence may start in the middle of a pattern > 2. There are one or two patterns, Pattern A and Pattern B in the > sequence > 3. Pattern A only consists of the numbers 0, 3, and 9. 3, 3 is always > followed by

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Arnaud Delobelle
Slaunger <[EMAIL PROTECTED]> writes: > I am a Python novice, and I have run into a problem in a project I am > working on, which boils down to identifying the patterns in a sequence > of integers, for example > > 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 3 0 3 3 0 3 3 0 10 6 6 > 1 6 6 1 6 6 1

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Banibrata Dutta
Haven't followed the entire thread, so I could be making a silly, out-of-place remark, and apologies in advance for the same.However, to me it looks like Slaunger wants to find 2 of the longest repeating patterns, and not just 2 specific patterns (though from the introductory test, it appears to be

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Gerard flanagan
Slaunger wrote: Hi all, I am a Python novice, and I have run into a problem in a project I am working on, which boils down to identifying the patterns in a sequence of integers, for example 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 3 0 3 3 0 3 3 0 10 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6

Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Slaunger
king for a "solution" to this specific problem, just some guidance The rules for the sequence is: 1. The sequence may start in the middle of a pattern 2. There are one or two patterns, Pattern A and Pattern B in the sequence 3. Pattern A only consists of the numbers 0, 3, and 9. 3, 3 is al

Re: Null object pattern

2008-11-12 Thread Robin Becker
arnestness requesting that None+42 == None, None() == None, and so on. This Nonesense was wisely rejected I agree with that decision. However, the behaviour you specify *is* useful (though I don't think ‘None’ should have that behaviour). It is the “Null object” design pattern, and may be

Re: Null object pattern

2008-11-11 Thread Terry Reedy
Ben Finney wrote: Terry Reedy <[EMAIL PROTECTED]> writes: We're not going to add the "feature" back that None compares smaller than everything. It's a slippery slope that ends with all operations involving None returning None -- I've seen a proposal made in all earnestness requesting that None+

Null object pattern (was: Python 3.0 - is this true?)

2008-11-11 Thread Ben Finney
earnestness requesting that None+42 == None, None() == None, and so > on. This Nonesense was wisely rejected I agree with that decision. However, the behaviour you specify *is* useful (though I don't think ‘None’ should have that behaviour). It is the “Null object” design pattern, and may be

Re: design pattern: MVC in python

2008-09-28 Thread 甜瓜
Really helpful! 2008/9/28 Mikolai Fajer <[EMAIL PROTECTED]>: > The following link directly discusses using MVC and pygame. > > http://ezide.com/games/writing-games.html > > -- > > -Mikolai Fajer- > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/lis

Re: design pattern: MVC in python

2008-09-27 Thread Mikolai Fajer
The following link directly discusses using MVC and pygame. http://ezide.com/games/writing-games.html -- -Mikolai Fajer- -- http://mail.python.org/mailman/listinfo/python-list

design pattern: MVC in python

2008-09-27 Thread 甜瓜
Howdy, I am working on a small PC game by using pygame. Since there are many graphical objects to display and intensive user interactions, I would like to employ MVC pattern to keep the system maintainable. However, I cannot find a good article which discussing the general knowledge about MVC

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: Help with Borg design Pattern

2008-06-30 Thread Maric Michaud
Le Monday 30 June 2008 10:52:24 Casey McGinty, vous avez écrit : > I'm running into a slight problem however that my run-time defined logging > level is not correctly set until after the module has initialized, > preventing any log messages from showing up. Is there a pythonic way to get > around t

Re: Help with Borg design Pattern

2008-06-30 Thread Casey McGinty
On Fri, Jun 27, 2008 at 5:25 PM, Maric Michaud <[EMAIL PROTECTED]> wrote: > Yes it is, but it's rather unneeded in Python, we prefer simply create a > module level dictionnary, these tricks are used in language like C++ or > Java. > > In python : > > mymodule.py : > > ModuleOptions = {} > > otherm

Re: Help with Borg design Pattern

2008-06-27 Thread Maric Michaud
Le Saturday 28 June 2008 03:47:43 Casey McGinty, vous avez écrit : > On Fri, Jun 27, 2008 at 3:21 PM, Casey McGinty <[EMAIL PROTECTED]> > > wrote: > > Hi, > > > > I'm trying to implement a simple Borg or Singleton pattern for a class > > that inherits

Re: Help with Borg design Pattern

2008-06-27 Thread Casey McGinty
On Fri, Jun 27, 2008 at 3:21 PM, Casey McGinty <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to implement a simple Borg or Singleton pattern for a class that > inherits from 'dict'. Can someone point out why this code does not work? > > class MyDict( dict

Help with Borg design Pattern

2008-06-27 Thread Casey McGinty
Hi, I'm trying to implement a simple Borg or Singleton pattern for a class that inherits from 'dict'. Can someone point out why this code does not work? class MyDict( dict ): __state = {} def __init__(self): self.__dict__ = self.__state a = MyDict() a['one'

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
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 stdlib includes a regular expression lib

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,

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,

Re: Null pattern

2008-06-19 Thread Ben Finney
George Sakkis <[EMAIL PROTECTED]> writes: > For example, consider the container methods __len__, __iter__ and > __contains__. The obvious choice for a null container is an empty > one. When taking __getitem__ into account though, the behaviour > looks inconsistent: > >>> Null[3] > Null >

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,

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

Null pattern

2008-06-19 Thread George Sakkis
I'd like to extend the Null pattern from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68205 to handle special methods (e.g. Null[3], del Null['key'], Null+1) but it's not always clear how to do it while keeping the behavior consistent and intuitive. For example, co

Re: Removing inheritance (decorator pattern ?)

2008-06-17 Thread George Sakkis
a situation where one class can be customized with several > > > > orthogonal options. Currently this is implemented with (multiple) > > > > inheritance but this leads to combinatorial explosion of subclasses as > > > > more orthogonal features are added. Natu

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 l

Re: Removing inheritance (decorator pattern ?)

2008-06-17 Thread Gerard flanagan
Maric Michaud wrote: Le Monday 16 June 2008 20:35:22 George Sakkis, vous avez écrit : On Jun 16, 1:49 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: [...] variation of your toy code. I was thinking the Strategy pattern, different classes have different initialisation strategies? But th

Pattern Matching Over Python Lists

2008-06-16 Thread Chris
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, ANY] so that is returns: [1, 2, [1, 2, [6, 7], 9, 9], 10] [1,

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread Maric Michaud
Le Tuesday 17 June 2008 05:10:57 Maric Michaud, vous avez écrit : > The class complextiy problem is actually solved by : > > inst_with_alg1 = MyClassUsingStrategies((algo1_strategy,), > (algo1_strategy,)) inst_with_alg1_alg2 = MyClassUsingStrategies( >                                              

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread Maric Michaud
his is implemented with (multiple) > > > inheritance but this leads to combinatorial explosion of subclasses as > > > more orthogonal features are added. Naturally, the decorator pattern > > > [1] comes to mind (not to be confused with the the Python meaning of > >

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread George Sakkis
ial explosion of subclasses as > > more orthogonal features are added. Naturally, the decorator pattern > > [1] comes to mind (not to be confused with the the Python meaning of > > the term "decorator"). > > > However, there is a twist. In the standard decorat

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread Gerard flanagan
George Sakkis wrote: I have a situation where one class can be customized with several orthogonal options. Currently this is implemented with (multiple) inheritance but this leads to combinatorial explosion of subclasses as more orthogonal features are added. Naturally, the decorator pattern [1

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread Diez B. Roggisch
> Ok, I see how this would work (and it's trivial to make it cache the > generated classes for future use) but I guess I was looking for a more > "mainstream" approach, something that even a primitive statically > typed language could run :) Even in Python though, I think of Runtime > Type Generati

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread George Sakkis
ultiple) > >> inheritance but this leads to combinatorial explosion of subclasses as > >> more orthogonal features are added. Naturally, the decorator pattern > >> [1] comes to mind (not to be confused with the the Python meaning of > >> the term "d

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread Diez B. Roggisch
ore orthogonal features are added. Naturally, the decorator pattern >> [1] comes to mind (not to be confused with the the Python meaning of >> the term "decorator"). >> >> However, there is a twist. In the standard decorator pattern, the >> decorator accepts the

Re: Removing inheritance (decorator pattern ?)

2008-06-15 Thread Terry Reedy
lasses as | more orthogonal features are added. Naturally, the decorator pattern | [1] comes to mind (not to be confused with the the Python meaning of | the term "decorator"). | | [1] http://en.wikipedia.org/wiki/Decorator_pattern I read the first part of the article. The following &qu

Re: Removing inheritance (decorator pattern ?)

2008-06-15 Thread Diez B. Roggisch
George Sakkis schrieb: I have a situation where one class can be customized with several orthogonal options. Currently this is implemented with (multiple) inheritance but this leads to combinatorial explosion of subclasses as more orthogonal features are added. Naturally, the decorator pattern

Removing inheritance (decorator pattern ?)

2008-06-15 Thread George Sakkis
I have a situation where one class can be customized with several orthogonal options. Currently this is implemented with (multiple) inheritance but this leads to combinatorial explosion of subclasses as more orthogonal features are added. Naturally, the decorator pattern [1] comes to mind (not to

Re: observer pattern (notification chain synchronization)

2008-05-11 Thread Ville M. Vainio
Alan Isaac <[EMAIL PROTECTED]> writes: > OK, thanks. > > Another approach is to begin with a set of stocks > > and remove them as they report. You can then trigger > > a report with the empty set instead of repeatedly > > calling ``all``. After a report the set can be > > "refilled". Ah, and I

Re: observer pattern (notification chain synchronization)

2008-05-11 Thread Ville M. Vainio
Alan Isaac <[EMAIL PROTECTED]> writes: > Here is one way: > > - for each fund, create a ``reportreceived`` dict that maps stocks to > booleans (initially False) > - as each stock notifies its funds, the fund changes False to True and checks > ``all(reportreceived.values())`` to determine whethe

Re: observer pattern (notification chain synchronization)

2008-05-10 Thread Alan Isaac
J. Cliff Dyer wrote: looks like a good approach to me OK, thanks. Another approach is to begin with a set of stocks and remove them as they report. You can then trigger a report with the empty set instead of repeatedly calling ``all``. After a report the set can be "refilled". Cheer

Re: observer pattern (notification chain synchronization)

2008-05-09 Thread J. Cliff Dyer
heers, Cliff On Fri, 2008-05-09 at 13:51 +, Alan Isaac wrote: > A question related to the observer pattern... > > Suppose I have a variant: there are stocks, mutual funds, and investors. Let > us say that funds are observers for multiple stocks, and investors are > observer

<    1   2   3   4   5   6   7   8   9   >