Test if IDLE is a mature program

Bengt Richter bokr at oz.net
Thu Jan 1 00:50:03 CET 2004


On Wed, 31 Dec 2003 20:04:24 +0100, =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= <martin at v.loewis.de> wrote:

>Aubrey Hutchison wrote:
>> Why do I need to tinker with it?
>> 
>> You don't need to tinker with mature programs.
>
>I readily admit that IDLE is not a
>"mature program".
>
>Happy now?
Perhaps Aubrey is fishing for suggestions he can't think of himself?
Or maybe he just enjoys the chiding role, who knows? ;-)

Anyway, there might be some use in thinking about the underlying issue, which ISTM
is occasional failures in robust handling of name clashes (which one could suspect
Aubrey might have contrived to demostrate with select.py, or maybe he just bumped into it).

One could program checks before importing, I suppose. Or, if being able to filter out
non-suitable modules on the import path were generally valuable, one could consider
inventing an optional check in the import mechanism itself.

E.g., if __import__ had an optional keyword argument like
    __import__(..., checkmeta=('cookie', 'some string'))

and file metadata could be declared with e.g.

     # -*- cookie: 'some string' -*-


in the first few lines, and if metadata were also stored in .pyc and .pyo files
for easy access without importing, then import could see the checkmeta optional
arg and do a pre-check for equality and if no match, continue searching per the path,
or raise an exception (perhaps an "assertmeta" spelling of the option to do that).

With this sort of thing in place, idle could presumably import what it really wanted,
and if Aubrey put # -*- cookie: 'some string' -*- in his select.py file, we could tell
him we think he intended the end result ;-)

One could also allow a sequence of tuples for multiple required checks, e.g.,
    __import__(..., checkmeta=(
                       ('cookie','something'),
                       ('coding','latin-1')))

(Don't tell Guido that some people might start putting # -*- version: 'xxx' -*- in their files,
and importing with checkmeta=('version','xxx') ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list