OO patterns with Python

Patrick Useldinger no at way.lu
Wed Feb 12 18:23:53 CET 2003


"Just" <just at xs4all.nl> wrote in message
news:just-D9CB4B.23360311022003 at news1.news.xs4all.nl...

>  Python makes it real easy as it isn't _purely_ OO, in the
> sense that you don't have to write a class to get "hello world" going.
> First you start to _use_ objects (eg. files, lists), learn what methods
> are. Then you learn what the mechanics of classes are, and you will
> slowly learn how to factor things into objects, and at that point
> patterns become interesting. Python is great for learning OO gradually.

Well, I think it's a blessing and a pitfall at the same time. I wrote some
small programs in Python, and of course, I didn't create one single class of
my own. Using classes is not so difficult, you write function(object) or
object(function), not a big deal. Like Visual Basic...

Recently, I had a case where I needed static variables, and didn't want to
resort to global variables. It was only *then* that it made 'click' and I
started to see what an object might be good for. And while I was at it, I
found other interesting uses.

So there is the pitfall: as you are not forced to be OO, at least not all
the time, you might find a million of ways to get around classes. So in that
way, Python is a bit risky, especially if you are lazy like I am.

--
email: 'dXNlbHBhQG15cmVhbGJveC5jb20=\n'.decode('base64')






More information about the Python-list mailing list