Why we will use obj$func() often

Mel Wilson mwilson at the-wire.com
Fri Apr 23 15:52:30 EDT 2004


In article <mailman.939.1082697809.20120.python-list at python.org>,
"Mike C. Fletcher" <mcfletch at rogers.com> wrote:
>Mark Hahn wrote:
>>My inability to understand this stuff is what drove me to do Prothon <grin>.
>>All the hidden wrapped this and wrapped that confused me to no end.

>Fascinating.  Most users never even notice this stuff, let alone getting
>so worked up about it that they start a whole separate language ;) .
>After all, they don't generally even know that metaclasses *exist* and
>just know that it all works exactly as they would expect.  You for
>instance, were describing how the interpreter just knows that a class
>can't be the target of an unbound class method.  Sure, *maybe* it's all
>a hideously complex mess that has people running screaming from Python
>in horror, but from where I sit it is an extremely elegant system that
>most people use without any impedance mismatch at all.

I perhaps encountered this..

    connection = serial.Serial ( ... )
        # connection is a file-like object,
        # having the usual `write` method

    engine = MyFiniteStateMachine ()
        # engine happens to have a `writer` method that
        # funnels out the machines products
        # The default is effectively `def writer (self, s): print s`

    engine.writer = connection.write
        # we channel engine's output through the serial connection

   Plugged together, it just works, as Mike says.  No
trouble when engine's internal calls to `self.writer` end up
accessing a completely different object's method.  It's only
lately that I've stopped to gawp at it, and wonder.

        Regards.        Mel.



More information about the Python-list mailing list