On Mon, Nov 10, 2014 at 10:31 AM, Chris Angelico ros...@gmail.com wrote:
So the semantics should be: If NameError would be raised (not
including UnboundLocalError, which still represents an error), attempt
to import the absent name. If successful, continue as if it had
already been done. If
On 11/12/2014 06:37 AM, Chris Angelico wrote:
On Mon, Nov 10, 2014 at 10:31 AM, Chris Angelico ros...@gmail.com wrote:
So the semantics should be: If NameError would be raised (not
including UnboundLocalError, which still represents an error), attempt
to import the absent name. If successful,
No bites? I'd have thought there'd be a few crazy ideas thrown out in
answer to this.
I was on vacation for a few days, so haven't been all that attentive
to my mail. I have an autoload module which does something similar
(note the Python 2.x syntax):
import sys, inspect, traceback, re
def
Chris Angelico ros...@gmail.com Wrote in message:
On Mon, Nov 10, 2014 at 10:31 AM, Chris Angelico ros...@gmail.com wrote:
So the semantics should be: If NameError would be raised (not
including UnboundLocalError, which still represents an error), attempt
to import the absent name. If
On Thu, Nov 13, 2014 at 1:56 AM, Skip Montanaro
skip.montan...@gmail.com wrote:
sys.excepthook = autoload_exc
I can't see a lot of people wanting this (I normally have its import
commented out in my PYTHONSTARTUP file), and I think it would probably
be bad practice for new users of the
On Thu, Nov 13, 2014 at 2:16 AM, Dave Angel da...@davea.name wrote:
I gave it a short whirl, just trying to make __missing__ work.
The type of globals () is a dict. I was able to add a
__missing__:myfunct to the instance but in order to work, the
__missing__ must be added as a class
On Wed, Nov 12, 2014 at 12:49 PM, Chris Angelico ros...@gmail.com wrote:
Interesting data point there - that you actually have it handy and
choose not to use it.
And, I believe I wrote it. Can't have a worse recommendation than
that. A cook who doesn't eat his own cooking. :-) I think I
On Thu, Nov 13, 2014 at 5:09 AM, Skip Montanaro
skip.montan...@gmail.com wrote:
On Wed, Nov 12, 2014 at 12:49 PM, Chris Angelico ros...@gmail.com wrote:
Interesting data point there - that you actually have it handy and
choose not to use it.
And, I believe I wrote it. Can't have a worse
Let's have some fun nutting out possible implementations for a bad idea :)
If you want a dictionary that prepopulates itself on demand, you
implement __missing__. Is there a way to implement the same thing for
the __main__ module? Since it isn't imported (as such), I don't think
switch out what's