things I wish python could do

Ryan Paul segphault at sbcglobal.net
Wed May 12 16:40:32 EDT 2004


I've spent a lot of time using python, and personally, I feel like it is
vastly superior when compared to languages like java, and c++, but there
are still a few things that detract from its elegance and flexibility. I
thought I might mention a few of them. I'd like to hear what people think
of my complaints, and I also like to hear the complaints of others.

1. many keywords (eg:try/except) are strictly imperative, and cannot be
used in a functional context.

this really should be possible: map(print,mylist)

2. there is no easy way to extend existing classes externally.

its possible, but it aint pretty...

class Shape:
  def __init__(self,numSides, perimeter):
    pass

Currently you can do this:

Shape.__dict__.update({
  'triangle':ClassMethod(
    lambda self,sideLength: Shape(3,sideLength*3))
  
  'square':ClassMethod(
    lambda self,sideLength: Shape(4,sideLength*4))
})

I want a way to extend a class as easily as I can define it.

3. you cant extend the builtins (string,list,etc), you have to inherit
them. Guido says he wont let us because it would create compatability
issues, and possibly break the interpreter. Maybe if we had namespace
functionality, that wouldnt be an issue?

4.  assignments cant be made inside of anonymous functions.

I think most python programmers will agree, that python emphasizes
simplicity, readability, and uniformity. Ultimately, I dont think that any
of those things are important enough to justify the reduction of
flexibility, syntactic mutability, and versatility. I was surprised to
find that Ruby solves all of my python complaints, while achieving
grace and simplicity easily comparable to that of python, and providing a
few innovative extras (including real private, public, and protected
methods).

Despite the fact that I disagree with quite a bit of the philosophy behind
prothon, I have enjoyed watching it, because it inspires good dialogue
about language development. (as long as those with closed minds keep their
mouths closed as well)

Are there are any strong reasons why a language shouldn't support the
things I list? Is anybody aware of features promised for future python
versions that solve or nullify my problems? Are any of my perceived
problems really just products of ignorance?



More information about the Python-list mailing list