Difference between 'function' and 'method'
gagsl-py2 at yahoo.com.ar
Fri Mar 7 10:40:22 CET 2008
En Thu, 06 Mar 2008 23:46:43 -0200, <castironpi at gmail.com> escribi�:
> oss.message is a abstraction class that writes the method name into a
> string, then sends it to OSS... outgoingserver or serverside.
> Now that I'm writing it, and this is important, -to- the -newsgroup-,
> I realize you could do it with a simple wrapper... include the
> function name in parameters and call the pickler and send.
> OSS then looks like this:
> def something_happens( *ar ):
> self.user_act( something_about( *ar ) )
> So the message.out() instance pickles ( 'user_act', ar ) and sends
> it. Then iss.incoming receives it, unpickles that string, gets
> 'user_act' from self, and invokes.
> The cool part is the declaration of user_act= message.out(), which
> uses a metaclass to assign its own name, and returns a function which
> includes the object in its signature. Cool.
> Yes it's working and a little slack. However-: this is the cool
> part. I'd like messages to know which instance they came from, and
> perform the sending & receiving encapsulated on their own--- not to
> subclass class SS( Sending ): with various behaviors: that is, to
> assign them as class attributes rather than superclasses.
You may look at the SimpleXMLRPCServer class and see how it implements
introspection. It's rather easy (and doesn't require metaclasses nor
decorators nor any other fancy stuff; I think it works the same since
Python 2.1). Apparently you're doing a similar thing, but using pickles
instead of xmlrpc.
More information about the Python-list