How to get/set class attributes in Python

Mike Meyer mwm at mired.org
Tue Jun 14 04:51:57 CEST 2005


Kalle Anke <skromta at gmail.com> writes:

> On Mon, 13 Jun 2005 20:41:48 +0200, Terry Hancock wrote
> (in article <mailman.391.1118687097.10512.python-list at python.org>):
>
>> 1) Assume the variables are of a sensible type (not 
>> necessarily the one you expected, though), and provide
>> exception handling to catch the case where their interface
>> does not match what you expect.
>
> The problem I have with this is that I might discover an error at runtime 
> instead of compile time, this means that I need to really exercise all 
> possible test cases to make sure that I've covered everything (which of 
> course is a good thing) but it would be easier to discover this at "compile 
> time".

But static typing only catches *some* of the errors that might
occur. Other errors will occur at run time even with static typing -
so you need to really exercise all possible test cases to make sure
you've covered everything in any case.

> (note: I'm not trying to change Python, only that to me statically typing has 
> it advantages also)

Static typing saves you some time by catching a small subset of
programming errors at compile time. On the other hand, it costs you
time by forcing you to declare a type for - well, everything that
you're going to catch errors for.

It's not clear which cost is larger.

     <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list