Something is rotten in Denmark...

Ian Kelly ian.g.kelly at gmail.com
Thu Jun 2 13:43:08 EDT 2011


On Thu, Jun 2, 2011 at 11:22 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> It seems to me that early binding is less flexible than late, because
> with late binding you have a chance to simulate early binding by saving a
> reference of the variable elsewhere, such as in a default value, or an
> instance attribute. But with early binding, you're stuck. There's no
> simple or straightforward way to simulate late binding in an early
> binding language.

Well, you can always do something like this:

>>> a = box(42)
>>> func = lambda x: a.value + x
>>> func(1)
43
>>> a.value = 6 * 9
>>> func(1)
55

I realize that's not exactly the same thing since you're stuck working
with "a.value" instead of just "a", but it does produce the desired
result.

Cheers,
Ian



More information about the Python-list mailing list