Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80615

Re: __missing__ for the top-level Python script

Path csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.06; 'method.': 0.07; 'source.': 0.07; 'subject:script': 0.09; 'yeah,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '(which,': 0.16; 'attribute,': 0.16; 'attributes.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'globals': 0.16; 'magic': 0.16; 'somehow,': 0.16; 'subject:top': 0.16; 'userdict': 0.16; 'wrote:': 0.18; 'module': 0.19; 'trying': 0.19; 'thu,': 0.19; 'work,': 0.20; 'cc:addr:python.org': 0.22; 'fairly': 0.24; 'cc:2**0': 0.24; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'specifically': 0.29; 'feature': 0.29; 'am,': 0.29; 'patch': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'work.': 0.31; 'code': 0.31; '13,': 0.31; 'convince': 0.31; 'enabled': 0.31; 'class': 0.32; 'worked': 0.33; 'implemented': 0.33; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'could': 0.34; 'knowledge': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'really': 0.36; 'doing': 0.36; 'next': 0.36; 'changing': 0.37; 'being': 0.38; 'nov': 0.38; 'short': 0.38; 'does': 0.39; 'sure': 0.39; 'dave': 0.60; 'most': 0.60; 'challenge': 0.61; 'kind': 0.63; 'more': 0.64; 'within': 0.65; 'hoping': 0.75; 'dict,': 0.84; 'dict.': 0.84; 'haha!': 0.84; "it'd": 0.84; 'presumably': 0.84; 'slots.': 0.84; 'angel': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=1GLjDPgyOsuD5iBZWP8Lhlc4g17aE0PkkfrHSEeTwqE=; b=VzsBCqdI3CeXcKFN3IJdl1m5LWURXWc643OYHS44sHaGVk5eZLixpJHwnlYU8gqOgR 0HkTCud4rCvJhhpsXfr5lcYHGadqoZ4oOCwBddDF1qnBQw/atvAHMhUTPvfo7z81ia1B pHwnEE1QpFmkt9oDQz3SAFhm3Uvpj0uWODtkCeqxp6wqfreB9M3A3us5yCCHKkd4gP+B DxVlKs/LE6+Q1Nv8/Pe1ce8jJzJYmJL3UvWhEvv1pGPQB4n6x+aqP5jonyMBH5f6pan1 D/EEivX04kT6fsCUwqkxKAcmpzOu9mUPimcwvJLVcsipF6YVIJSj+BgFP9AGZIGyu3TW WQhg==
MIME-Version 1.0
X-Received by 10.50.110.4 with SMTP id hw4mr41586701igb.14.1415814740185; Wed, 12 Nov 2014 09:52:20 -0800 (PST)
In-Reply-To <m3vtjk$c3b$1@ger.gmane.org>
References <CAPTjJmpVVfPzwrbeornk9Txyfiz+H5MDfHG2nY_9va7RCUEmEw@mail.gmail.com> <CAPTjJmrhz7crC2_x+ZN9sLgPvd8B1Yn8skzMSTBXJ6gSj55TqQ@mail.gmail.com> <m3vtjk$c3b$1@ger.gmane.org>
Date Thu, 13 Nov 2014 04:52:20 +1100
Subject Re: __missing__ for the top-level Python script
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15731.1415814749.18130.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1415814749 news.xs4all.nl 2852 [2001:888:2000:d::a6]:52359
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:80615

Show key headers only | View raw


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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: __missing__ for the top-level Python script Chris Angelico <rosuav@gmail.com> - 2014-11-13 04:52 +1100

csiph-web