2001 Enchancement Wishlist
Alex Martelli
aleaxit at yahoo.com
Fri Dec 29 18:23:34 EST 2000
"Raymond Hettinger" <othello at javanet.com> wrote in message
news:3A4CEACB.220998A0 at javanet.com...
> If these ideas meet with favor, I'll write-up a PEP.
>
> 1. List.append(elem) and List.pop() are great. Let's add two more
> methods, List.prepend(elem) and List.leftpop(). The goal is to
Pass (apart from the unhappy names); I think .insert, and slice
assignment in general, are by far enough, but it's a min.r.
> 2. There is already a PEP to extend the eval() function which is currently
> limited to dictionaries. The goal is to accept any object defining
> __getitem__() so that any mapping object can be used to specify the
> globals and locals. I recommend that we extend the same courtesy to
> the % string formatting operator. For example:
Sure, the more polymorphism, the merrier. That one I'd like to see.
> 3. __init__ is the only special method that doesn't allow a return value.
I think it's better off without one, just as it is now. Use factory
functions if you want to generate with more freedom, and let
class objects as callable make-and-initialize new instances.
> 4. Allow dictionaries to respond to sequence operations as if .keys()
were
> in the list object. Examples:
>
> knights = { 'lancalot':'good', 'gallahad':'brave', 'robin':'coward' }
[snip]
> print knights[0] # may be any one depending on the hash
table
Unfeasible. 0 (or any other int) might be a key (and it may happen to
fall anywhere in the hash table order, too). So what does knights[x]
mean -- the value corresponding to key x is present, as now; or, the
value corresponding to key x is present, or else if x is (or, can be
coerced to?) int, the x-th key in hashtable order? The latter is far
too complex -- and all the complexity for very little gain.
This one would be a real blooper if Python adopted it, IMHO.
Alex
More information about the Python-list
mailing list