A while back i had learned about the 'with' statement and at first I naively thought that it worked similarly to a with statement I was familiar with, from delphi/pascal - obviously it doesn't and I was instantly hit with the idea of how useful it would be to have a keyword that could use a namespace from an object, hitting the familiar __getattr__ functions and related.

the keyword I proposed would be 'interrogate' (which is rather long, could use another one like 'using' or something) but.. thats not really important to me, the idea is, so

class test():
   def __init__(self):
      self.x = 42

foo = test()
bar = test()
x = 33
bar.x = 22
interrogate foo, bar:
  print x

-----

output is 42 since x is found inside of foo before bar, and locals would be interrogated last, but a more usefull example would be ..

class test():
  def __getattr__(self, name):
    if len(name) == 1 and (ord(name) in range(ord('a'), ord('z'))) :
      return ord(name)


test_ns = test()

interrogate test_ns:
  print a

----
output is 97

using the above example lexical closures may be awkward to implement in the language itself, this is a bit of a contrived example.. but.. eh..

# if I understand python enough, then I believe that when we enter this block, and create variables, they go out of scope,
# and there are no exceptions to this rule, ever so .. in order to implement mine obviously scope would be the same
# mechanism so I have oh_bother declared in the local namespace first

oh_bother = None
interrogate test_ns:
  def geronimo():
    return z
  oh_bother = geronimo

print oh_bother()
---
output is 122

--
-Prozacgod

"Prozac may heal the mind, but friends can mend the soul"