beginner question: extending python types

Uwe Mayer merkosh at hadiko.de
Tue May 14 16:00:09 EDT 2002


In article <y%WD8.38698$CN3.1349890 at news2.tin.it>, aleax at aleax.it 
says...
> Uwe Mayer wrote:
>         ...
> > I want to force certain parameters of methods to be of a specific type,
> 
> If you really want this, you chose the wrong language.  Most languages
> devote substantial amounts of mechanism to such 'bondage' issues.
> 
> Python distinguishes itself from by far most languages by NOT doing
> this, which is from where much of its extra power comes -- from where
> much of the incredible productivity boost it gives programmers comes.

I come from a Perl background and am familiar with an interpreter being 
fuzzy on types.
However Python provides a much stronger support for OOP and overloading 
operators. I'm a little confused:
In the python library reference they talk of "Iterator Types" while as 
far as I can see talking of a protocoll or an interface (as in Java) 
would be more appropriate.
I like Pythons long integer arithmetrik: reduce(lambda x,y: x*y, range
(1,10000))
actually returns a result! and  IDLE is just what I need, so I would 
very unhappyly switch language.
However I am not sure how to feel about this. The Java way would be to 
say: Ok, if it supports xyz interface I can work with it, but in python 
I'll just have to assume I'm passing the right operands later on.
On the other hand I'd be investing much time in trying to keep my 
classes foolprove...
 
> But if you want to do this, in Python you're "fighting city hall", going
> against the grain of the language.  Choose another.  I recommend
> Haskell, whose typing system is really wonderful.  You'll get compile
> time checking of your types, exactly as strong or weak as you want
> it to be.  Choosing Python and then going typechecking will reduce
> or countermand Python's productivity gain AND still never get as far
> nor as deep as a statically-checking language would -- a _good_
> one, at least (forget the mishmash mis-called a "type system" in
> such languages as C++ or Java -- go for Haskell, or ML in some
> variant or other).

Haskell... does that sound like Gopher to me? Functional programming 
language?
Hmmmm....
 
> I don't think you _need_ this typechecking, though I can't know your
> situation enough to be sure.  But whether you need it or not, if you're
> going to use it, drop Python in favour of some statically-typechecked
> functional language with a good typesystem.  This is my advice.

I'll rather skip the type checking. Python looks good so far. I'm just a 
little insecure on how to do things yet.

Thanks for the response!
Uwe



More information about the Python-list mailing list