Migrating to perl?

Remco Gerlich scarblac at pino.selwerd.nl
Fri Jan 5 02:09:20 EST 2001


Joel Ricker <joejava at dragonat.net> wrote in comp.lang.python:
> From your examples, Pythons class model is much cleaner.  Also if I
> understand your example, variables internal to the object are kept
> internal -- they can't be accessed without a proper method.

This is not true, just the way he did it.

In Python, nothing is ever private, you can always inspect and change
everything. It's very dynamic. The programmer has the responsibility to
decide when he wants to use the dynamic things.

In most cases you won't need that power, so you don't use it. In very few
cases, you'll be very happy with the flexibility :).

> With perl
> anything goes.  There are some techniques to prevent this but it isn't
> definite.  Its actually this very topic that made me throw my new OO book
> across the room and subscribed to this newsgroup :)

Well, then let's say that you came here to see this is not all bad :)

> I've mentioned before that I'm real new to OO.  How should I approach it in
> Python?  Has anyone learned OO just from Python?  Or should I study OO
> theory else where and then apply it to Python?  I know this is bordering on
> the question of how do I do OO but I really know very little about it...
> enough to know that I can benefit from it and basic ideas.  I understand the
> idea of a class and building objects from it but anything beyond that is
> still really new to me.  Any suggestions?

There is not much more to it. When you have a data structure, possibly
pretty complex, with functions that work on data of that type, make it into
an object.

In large projects, the hairy thing is deciding which objects to make, how
your module structure should look like, etc. There are some books for that
but experience is most important in my opinion. (People will disagree here -
don't start a discussion, just list some good books ;)).

> I heard something about curley braces as well.  No {} for blocks?  Thats
> going to take some getting used to :)

Did you see his class example? That is how it looks. I love it.

-- 
Remco Gerlich



More information about the Python-list mailing list