On Sun, Aug 26, 2012 at 11:43 PM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > It gets worse: Python has multiple namespaces that are searched. > > "Go to the Excelsior Hotel and ask the concierge for Mr Smith. If Mr > Smith isn't staying there, go across the road to the Windsor Hotel and > ask there. If he's not there, try the Waldorf Astoria, and if he's not > there, try the Hyperion."
Does it? I thought the difference between function-scope and module-scope was compiled in, and everything else boils down to one of those. Explicit dot notation is different ("ask for Mr Smith, then ask him where his packages box is, and put this in the box"). Hmm, okay, there's something slightly different with closures. But it's still unambiguous at compile time. >>> x=1 >>> def foo(y): return lambda z: x+y+z >>> foo(2)(3) 6 >>> import dis >>> dis.dis(foo(2)) 2 0 LOAD_GLOBAL 0 (x) 3 LOAD_DEREF 0 (y) 6 BINARY_ADD 7 LOAD_FAST 0 (z) 10 BINARY_ADD 11 RETURN_VALUE What multiple namespaces are you talking about, where things have to get looked up at run time? ChrisA -- http://mail.python.org/mailman/listinfo/python-list