Am 10.01.2013 13:48, schrieb Peter Otten:
If you adopt this approach you might omit the lookup dictionary and use
getattr():

...     @classmethod
...     def handle_foo(cls): print "Hello from B.handle_foo()"
...     @classmethod
...     def get_handler(cls, packet_type):
...             return getattr(cls, "handle_" + packet_type)
...
Well I think this is an elegant solution.

But due to my protocol a packet type is uniquely defined by a combination of two header fields (that contain integers). Building a verbose method name from these would complicate it again.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to