Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80615 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2014-11-13 04:52 +1100 |
| Last post | 2014-11-13 04:52 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: __missing__ for the top-level Python script Chris Angelico <rosuav@gmail.com> - 2014-11-13 04:52 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-11-13 04:52 +1100 |
| Subject | Re: __missing__ for the top-level Python script |
| Message-ID | <mailman.15731.1415814749.18130.python-list@python.org> |
On Thu, Nov 13, 2014 at 2:16 AM, Dave Angel <davea@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 attribute, a method. And > dict, being implemented in C, doesn't let you add class > attributes. Presumably the C code does the equivalent of > slots. Yeah, I tried doing some of that kind of work and failed. Was hoping someone with more knowledge of internals could pull it off. > So the next thing to try would be to try to force the module > dictionary to be a userdict without slots. Then we could add the > necessary method. But that would be changing the python source. I > wasn't sure that was within the challenge constraints. Haha! Well, unless we can convince people that this would really be a good feature (which, somehow, I doubt...), not really. Though if it can be enabled with a tiny patch to Python and then most of the magic worked in PYTHONSTARTUP, that might do... but I suspect it'd need to be fairly specifically coded. ChrisA
Back to top | Article view | comp.lang.python
csiph-web