Python Macros

Jacek Generowicz jacek.generowicz at cern.ch
Wed Oct 6 09:13:23 CEST 2004


Richard Blackwood <richardblackwood at cloudthunder.com> writes:

> Andrew Dalke wrote:
> 
> > Jacek Generowicz wrote:
> >
> >> _Most_ object-oriented languages support object orientation via the
> >> message passing paradigm. Python included.
> >
> >
> > Translating the Smalltalk notation to Python -- what are
> > the messages?  Is it that
> >
> >   x.y(z)
> >
> > means "send the __call__  (z)" message to the result of
> > the "z __getattr__ 'y'" message?
> >
> >                 Andrew
> >                 dalke at dalkescientific.com
> 
> In ObjC it would be send the message y with value z to object X
> Say X doesn't know what to do with y
> specified in X's code are instruction that tell it what object to pass
> the message y to...say...U for example
> 
> So the message has been passed and basically translates into U.y(z) or
> in ObjC [U y:z]

You mean some refinement of this sort of thing:

    class X(object):
    
        a = "lives in X"
    
        def __getattr__(self, name):
            return getattr(U,name)
    
    class U(object):
    
        b = "lives in Y"
    
    x = X()
    print x.a
    print x.b

?



More information about the Python-list mailing list