Frank Millman fr...@chagford.com wrote:
Apologies for the triple-post.
I use google-groups for reading c.l.py, but I know that some people reject
messages from there due to the volume of spam, so on the odd occasion when I
want to send something I fire up Outlook Express and send it from
Anthony Tolle wrote:
To take things one step further, I would recommend using decorators to
allow symbolic association of functions with the message identifiers,
as follows:
[...]
That's neat. Thanks.
Frank
--
http://mail.python.org/mailman/listinfo/python-list
Dave Angel wrote:
OK, that makes good sense. And I withdraw any suggestion to use pickling,
since that could be subject to hacking.
It now appears that the messages are only incidentally GUI events. And
that you would be well advised to make every possible event a separate
message, so
Dave Angel wrote:
Any time I see multiple lists like that which have to stay in
synch, I think code-smell.
I don't think it is that bad, but I agree there is always room for
improvement.
Why not let the EVT's be passed as strings, and avoid the whole mapping
to integers and mapping
Dave Angel wrote:
Show me a sample client event handler, and maybe I can suggest how to
encode it. For example in wxPython, events are encoded with
an event
object. You could have the event send the object's type-string as an
event ID. No lookup at all. And in fact, one event
Frank Millman wrote:
Dave Angel wrote:
Show me a sample client event handler, and maybe I can suggest how to
encode it. For example in wxPython, events are encoded with
an event
object. You could have the event send the object's type-string as an
event ID. No lookup at all. And in
Dave Angel wrote:
Frank Millman wrote:
That is definitely *not* what I want to do.
I want to make the server as generic as possible, so that
it can handle any
type of client, hopefully even including a browser
eventually. Therefore the
server has no knowledge of wxPython event
To take things one step further, I would recommend using decorators to
allow symbolic association of functions with the message identifiers,
as follows:
==
(MESSAGE_ONE
,MESSAGE_TWO
,MESSAGE_THREE
) = xrange(3)
class MyClass(object):
method_dict = {}
Frank Millman wrote:
Dave Angel wrote:
Frank Millman wrote:
That is definitely *not* what I want to do.
I want to make the server as generic as possible, so that
it can handle any
type of client, hopefully even including a browser
eventually. Therefore the
Hi all
I have a class that uses a dictionary to map message numbers to methods.
Here is a simple example -
class MyClass(object):
def __init__(self):
self.method_dict = {}
self.method_dict[0] = self.method_0
self.method_dict[1] = self.method_1
On Wed, Aug 26, 2009 at 1:22 AM, Frank Millmanfr...@chagford.com wrote:
Hi all
I have a class that uses a dictionary to map message numbers to methods.
Here is a simple example -
class MyClass(object):
def __init__(self):
self.method_dict = {}
On Aug 26, 10:54 am, Chris Rebert c...@rebertia.com wrote:
On Wed, Aug 26, 2009 at 1:22 AM, Frank Millmanfr...@chagford.com wrote:
A
class MyClass(object):
def on_message_received(self, msg):
self.method_dict[msg](self)
def method_0(self):
print 'in method_0'
On Aug 26, 10:54 am, Chris Rebert c...@rebertia.com wrote:
On Wed, Aug 26, 2009 at 1:22 AM, Frank Millmanfr...@chagford.com wrote:
A
class MyClass(object):
def on_message_received(self, msg):
self.method_dict[msg](self)
def method_0(self):
print 'in method_0'
On Aug 26, 10:54 am, Chris Rebert c...@rebertia.com wrote:
On Wed, Aug 26, 2009 at 1:22 AM, Frank Millmanfr...@chagford.com wrote:
A
class MyClass(object):
def on_message_received(self, msg):
self.method_dict[msg](self)
def method_0(self):
print 'in method_0'
Frank Millman wrote:
On Aug 26, 10:54 am, Chris Rebert c...@rebertia.com wrote:
On Wed, Aug 26, 2009 at 1:22 AM, Frank Millmanfr...@chagford.com wrote:
A
class MyClass(object):
def on_message_received(self, msg):
self.method_dict[msg](self)
def method_0(self):
print
MRAB pyt...@mrabarnett.plus.com wrote in message
news:mailman.444.1251290454.2854.python-l...@python.org...
An alternative is:
class MyClass(object):
... def on_message_received(self, msg):
... try:
... getattr(self, method_%d % msg)()
... except
Frank Millman wrote:
MRAB pyt...@mrabarnett.plus.com wrote in message
news:mailman.444.1251290454.2854.python-l...@python.org...
An alternative is:
class MyClass(object):
... def on_message_received(self, msg):
... try:
... getattr(self, method_%d %
17 matches
Mail list logo