Re: Factory pattern implementation in Python

2006-12-04 Thread Gabriel Genellina
At Monday 4/12/2006 13:39, [EMAIL PROTECTED] wrote: class Factory: def __isValidEventClass(self, obj): if inspect.isclass(obj) and obj != events.EvtBase and \ events.EvtBase in inspect.getmro(obj): for m in inspect.getmembers(obj): if m[0] == 'eventNum': ret

Re: Factory pattern implementation in Python

2006-12-04 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dennis Lee Bieber: >> Presuming the is a type code I'd just set up a list of >> functions: >> Then create a dictionary of them, keyed by the code >> processors = { "1" : process_1, >> "2" : process_2, >> >> "x" : process

Re: Factory pattern implementation in Python

2006-12-04 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dennis Lee Bieber: >> Presuming the is a type code I'd just set up a list of >> functions: >> Then create a dictionary of them, keyed by the code >> processors = { "1" : process_1, >> "2" : process_2, >> >> "x" : proces

Re: Factory pattern implementation in Python

2006-12-04 Thread bearophileHUGS
Dennis Lee Bieber: > Presuming the is a type code I'd just set up a list of functions: > Then create a dictionary of them, keyed by the code > processors = { "1" : process_1, > "2" : process_2, > > "x" : process_x } Jus

Re: Factory pattern implementation in Python

2006-12-04 Thread George Sakkis
Romulo A. Ceccon wrote: > George Sakkis wrote: > > > If you actually intend to > > 1) name your Event subclasses Evt1, Evt2, ... EvtN and not give more > > descriptive (but unrelated to the magic event number) names > > No, those names are just an example. The actual classes have > descriptive name

Re: Factory pattern implementation in Python

2006-12-04 Thread Romulo A. Ceccon
George Sakkis wrote: > If you actually intend to > 1) name your Event subclasses Evt1, Evt2, ... EvtN and not give more > descriptive (but unrelated to the magic event number) names No, those names are just an example. The actual classes have descriptive names. > By the way, it is not clear from

Re: Factory pattern implementation in Python

2006-12-04 Thread Chris Mellon
On 4 Dec 2006 08:39:17 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi, > > I need to parse a binary file produced by an embedded system, whose > content consists in a set of events laid-out like this: > > ... > > Every "event" is a single byte in size, and it indicates how long is >

Re: Factory pattern implementation in Python

2006-12-04 Thread George Sakkis
[EMAIL PROTECTED] wrote: > Hi, > > I need to parse a binary file produced by an embedded system, whose > content consists in a set of events laid-out like this: > > ... > > Every "event" is a single byte in size, and it indicates how long is > the associated "data". Thus, to parse all events

Factory pattern implementation in Python

2006-12-04 Thread googlegroups
Hi, I need to parse a binary file produced by an embedded system, whose content consists in a set of events laid-out like this: ... Every "event" is a single byte in size, and it indicates how long is the associated "data". Thus, to parse all events in the file, I need to take it like a st