Typing arguments in python

Peter Hansen peter at engcorp.com
Wed Apr 16 16:31:06 CEST 2003


Danra wrote:
> 
> Here's an idea I've been playing with for a syntax for type checking
> in python. 
>[snip]
> The advantages of the second definition are obvious - The fact that
> the argument passed doesn't have the write method would be detected
> immediately, rather than when trying to call the it.
> 
> Why is that so important? Well, for starters in many cases it isn't.
> In a simple script or application it really is sufficient to get the
> exception only when calling write.
> 
> But - what if:
> 
> 1) The stuff you do before calling write takes a lot of time, which
> could be saved if the error is detected when the function is called.

Uh, wouldn't this happen only *once*, anyway, since this represents
a fundamental flaw in the code?  On top of that, if you are doing proper 
testing, you would never release this code, so who cares that it takes
lots of time before it fails?

> P.S. I am not a expert on python or anything of the sort. It could be
> that all of the above is just balderdash in your opinions, in which
> case feel free to say so :)

Well, I wouldn't use a nasty word like "balderdash" (oh shit, I just did!)
in this family forum, but issues very similar to this _have_ been 
raised and discussed repeatedly in the newsgroup and the idea rarely
catches much "traction".

-Peter




More information about the Python-list mailing list