Peter Marklund

Peter Marklund's Home

Sat May 29 2004 05:00:00 GMT+0000 (Coordinated Universal Time)

Opening a File

Bruce Eckel on why he loves Python:

They say you can hold seven plus or minus two pieces of information in your mind. I can't remember how to open files in Java. I've written chapters on it. I've done it a bunch of times, but it's too many steps. And when I actually analyze it, I realize these are just silly design decisions that they made. Even if they insisted on using the Decorator pattern in java.io, they should have had a convenience constructor for opening files simply. Because we open files all the time, but nobody can remember how. It is too much information to hold in your mind.

Here is how you open a file in Python: "for line in file('filename').readlines():,". I'm increasingly motivated to learn Python and also to have a closer look at Plone.