Regarding coding style
sjdevnull at yahoo.com
sjdevnull at yahoo.com
Sun Mar 9 07:25:07 CET 2008
On Mar 9, 12:09 am, Steven D'Aprano <st... at REMOVE-THIS-
> On Sat, 08 Mar 2008 20:45:25 -0800, sjdevn... at yahoo.com wrote:
> > On Mar 8, 7:34 pm, Steven D'Aprano <st... at REMOVE-THIS-
> > cybersource.com.au> wrote:
> >> On Sat, 08 Mar 2008 19:31:47 +0000, Grant Edwards wrote:
> >> > I'm also a bit baffled by people who put a comment at the top of
> >> > every file that tells you what the filename is.
> >> [snip rant]
> >> You've never printed out a source file on pieces of dead tree to read
> >> on the train on the way home, or in bed or the bath?
> >> Yes, some editors will print a header or footer showing the file name,
> >> but not all will, or are configured to do so.
> > The only times I can recall printing source were in college classes
> > where I was required to hand in a hardcopy with the assignment and code
> > samples for job interviews. In the real world the code base tends to be
> > too huge to contemplate printing...
> You've never (say) printed out the source code to one of the modules in
> the Python standard library to read and study?
Nope. It's a lot easier to read on the computer, with searching,
proper syntax highlighting, tags, etc and access to all the other
information I might want while reading the code, and the ability to
drift to other modules that might be imported/mentioned, find examples
using them, etc.
> If your code base is so huge that you can't print out any meaningful
> piece, then you desperately need more encapsulation.
Yeah, most of the code is encapsulated into smaller parts. The
problem is figuring out what meaningful piece(s) I might want. How
often do you really find yourself knowing ahead of time exactly what
you want to read? Even in code reviews it's common to look at other
files in the system, version control history, the issue/spec tracker,
or even wander off into Python documentation, algorithm papers, or
whatever. It just doesn't seem worth playing a guessing game about
exactly what code/versioning/docs/etc I might want to have on hand
when the net result even if I guess right will be a worse reading
experience without searching, tags, bookmarks, etc.
> > Even in the early 1990s the moral equivalent of enscript (I think it was
> > a2ps) worked just fine for printing with filenames, line/page numbers,
> > and other niceties no matter what editor you used. It seems more
> > reasonable to mandate using a sane print tool for the odd case where
> > someone wants to print things out than to mandate cluttering up every
> > file with the filename in a comment.
> Sure, but really, adding ONE LINE to the start of a file is hardly
> "cluttering up" anything.
It's not terrible, no, just vaguely pointless and a bit fragile in the
face of change.
More information about the Python-list