Python Macros

Carlos Ribeiro carribeiro at gmail.com
Mon Oct 4 17:27:48 EDT 2004


On Mon, 04 Oct 2004 12:19:16 -0700, Josiah Carlson <jcarlson at uci.edu> wrote:
> 
> > Not sure I understand you here.  I want to implement messages like in
> > ObjC where if you send a msg to an object and that object does know what
> > to do with it, it can send the obj automatically to another object which
> > might know what to do with it.
> >
> > Anyhow, there are other reasons as well.
> 
> What are called "messages" in ObjC, are generally known as "instance
> methods" in Python.
> 
> I would imagine in ObjC you would do something like the following:
> 
> object.send('operation', arg1, arg2, arg3,...)
> send(object, 'operation', arg1, arg2, arg3,...)
> 
> In Python, that becomes:
> 
> object.operation(arg1, arg2, arg3,...)
> 
> "Messages" in ObjC are really just a metaphor, one that is shared by
> Smalltalk, but not many other object-oriented languages.

There are many things that can be done to mimic it. Instance methods
in Python are pretty powerful -- they can be handled like normal
objects, copied, passed as parameters, and even bound to other classe.
You can also use descriptors in Python to do something similar. More
details would be needed though for better discussion.

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list