Re: How does "delegation" work as per the FAQ?

From: Jeff Epler (jepler_at_unpythonic.net)
Date: 12/25/03


Date: Thu, 25 Dec 2003 14:20:57 -0600
To: Rene Pijlman <reply.in.the.newsgroup@my.address.is.invalid.unpythonic.net>

In Python, there's little difference between
        f = o.m
        f(3)
and
        o.m(3)
either way, the attribute 'm' is looked up on o in exactly the same
way. So the delegation pattern works no matter whether 'o.m' is a
method or is data.

Jeff



Relevant Pages

  • Re: Dictionary to tuple
    ... matter. ... (or if you're using an older version of Python without the ... Jeff ...
    (comp.lang.python)
  • Re: Whats so funny? WAS Re: rotor replacement
    ... It also is a matter of code size, ... > separate module, then we wouldn't need this discussion. ... people who want an AES module for Python could get one ... Maybe Bryan Mongeau will contribute this code to Python some day. ...
    (comp.lang.python)
  • Re: Defaultdict and speed
    ... t = clock() ... With Python it's usually difficult to tell if some performance ... most other programs it doesn't matter. ... the performance tweaks I may invent in the future too. ...
    (comp.lang.python)
  • Re: Python -- (just) a successful experiment?
    ... No matter how much you include, ... but Package Y is much better at doing foo than ... > massive installer. ... > iteration of MacEnthon, at least, is going to be based on Python eggs ...
    (comp.lang.python)
  • Re: Embedding Python in a multi-threaded C++ application
    ... Jeff thanks for the prompt reply. ... Lets say I won't terminate a thread that is running, ... python module and runs a single method from that module. ... even a simple signaling mechanism would solve the problem in this ...
    (comp.lang.python)