[Python-3000] A few small py3k wishes

Talin talin at acm.org
Sun Apr 2 23:39:56 CEST 2006


Just a few things that have wanted while doing python
programming. Maybe some of these are already doable
or are already on someone's wish list...

-- The __main__ module should contain a file path like imported
modules. in other words, every module should know where it
came from. In fact, I see no reason why the __main__ module
should have any different attributes than an imported module
other than the name.

-- An easy way to make a case-insensitive, case-preserving
dict that works with regular string keys.

-- An easy way to iterate over key, value pairs in a dict in
sorted order. Currently you have to get the list of keys,
sort them, and then lookup each value, OR you have to
get the list of tuples and call sorted() with a key= arg
containing a lambda function that extracts the first
tuple element.

(Another one of my wild ideas was an "order by"
clause for list comprehensions, but let's not go there.)

-- A simple way to import all modules in a directory
(this would be used for plugins)

-- A mechanism whereby imported modules can import
symbols from the module that imported them. (Specifically,
I want to take a bunch of variables in my __main__ module
and make them accessible to the imported module.)

-- The module class should have a method to iterate
over child modules. Currently you can iterator through
all of its attributes, but you have to filter out which ones
are modules.

-- A path-globbing function that supports regex-style
captures.

-- A path-globbing function that supports the
perforce-style syntax "..." (three dots) to mean "all descendants".
So for example, "foo/.../*.cpp" matches any cpp files in
foo or any of its subdirectories.

That should be enough for the moment.

-- Talin




More information about the Python-3000 mailing list