Class Variable Question

Steve Holden sholden at holdenweb.com
Tue Apr 10 13:28:22 EDT 2001


"Russell E. Owen" <owen at astrono.junkwashington.emu> wrote in message
news:9aveat$10aq$1 at nntp6.u.washington.edu...
> 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 absolutely confident of this, but I thought Self used the
prototyping approach, and what differentiates it from SmallTalk (and Python
too, for that matter) is that any *instance* can act as a protoype for other
instances. Thus you create a prototype instance, and effectively use it as
the class model.

If I'm wrong I'll be happy to be educated.

> 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.
>
I don't think too much of Python is the way it is because of ease of
implementation. More because the language as designed offers a usable
orthogonal feature set which suits pragmatic programmers well.

regards
 Steve






More information about the Python-list mailing list