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.<br>


<br>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<br><br>class test():<br>   def __init__(self):<br>


      self.x = 42<br><br>foo = test()<br>bar = test()<br>x = 33<br>bar.x = 22<br>interrogate foo, bar:<br>  print x<br><br>-----<br><br>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 ..<br>


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


  print a<br><br>----<br>output is 97<br><br>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..<br><br># if I understand python enough, then I believe that when we enter this block, and create variables, they go out of scope,<br>


# and there are no exceptions to this rule, ever so .. in order to implement mine obviously scope would be the same<br># mechanism so I have oh_bother declared in the local namespace first<br><br>oh_bother = None<br>interrogate test_ns:<br>

  def geronimo():<br>    return z<br>  oh_bother = geronimo<br><br>print oh_bother()<br>--- <br>output is 122<br><br>-- <br>-Prozacgod<br><br>"Prozac may heal the mind, but friends can mend the soul"<br>