Class Variable Question

Russell E. Owen owen at astrono.junkwashington.emu
Tue Apr 10 13:02:18 EDT 2001


In article <FXjA6.122384$5H6.4754528 at e420r-atl2.usenetserver.com>,
 "Steve Holden" <sholden at holdenweb.com> wrote:

>That's correct. Python gives you "enough rope to shoot yourself in the
>foot", and so does not offer the protection schemes associated with
>statically-types languages like Java and C++. This increases the flexibility
>of the language, at the (slight) risk of errors which would not occur in
>Java or C++.

I just wanted to point out that there are dynamically typed languages 
that do not allow modifying instances once they are created (except by 
modifying the class itself). Smalltalk is an excellent example. Dynamic 
typing is a wonderful thing and one of Python's many strengths. However, 
being able to modify instances is less obviously a positive feature.

I believe the Python's way is called "prototyping". A class is a 
prototype or object factory for creating new objects. Once you get the 
object you can do anything you like with it.

I'm not a big fan of prototyping for several reasons:
- typos can cause the kind of damage you mentioned
- it complicates type checking, implementation of safe interfaces, etc.

However, it presumably does have uses, and it hasn't caused much trouble 
for me, so I'm not complaining too hard. On the whole Python is a very 
nice language -- a reasonable class implementation, nice exception 
handling, good collection classes, runs on nearly everything, good for 
large and small projects...

My guess is that the reason Python uses prototyping is that it was 
simpler to implement the language that way.

-- Russell



More information about the Python-list mailing list