On Mon, Dec 29, 2014 at 1:15 AM, Skip Montanaro <skip.montan...@gmail.com> wrote: >> We were discussing something along these lines a while ago, and I >> never saw anything truly satisfactory - there's no easy way to handle >> a missing name by returning a value (comparably to __getattr__), you >> have to catch it and then try to re-execute the failing code, which >> isn't perfect. How does yours work? Or was it one of the ones that was >> mentioned last time? > > Just like that. I've attached a copy. As you said, I'm sure it's not > perfect, but it's handy in precisely those interactive interpreter > cases when *dope slap* you forgot to import a standard module before > launching into a block of code.
Right, so its primary imperfection is that it potentially re-executes a block of code that had partially succeeded. Still of value, but definitely has its dangers. I wonder how hard it would be to tinker at the C level and add a __getattr__ style of hook... ChrisA -- https://mail.python.org/mailman/listinfo/python-list