[Tutor] Re: python_naming_conventions - newbie
Andrei
project5 at redrival.net
Fri Oct 17 10:17:41 EDT 2003
Rahul Kumar wrote:
> As someone learning python after several years of working on Java, i am
> interested to know why does python follow the
> lower_case_with_underscores way of naming methods and variables while
> Java follows the MixedCaseWithoutUnderscores.
Does it? It's not really true. The conventions for this kind of stuff are in the
Style Guide:
http://www.python.org/doc/essays/styleguide.html
The recommendations for camelCase, MixedCase and under_scores are quite murky
IMO, here's a quote: "CapWords style is used for functions that provide major
functionality (e.g. nstools.WorldOpen()), while lowercase is used more for
"utility" functions". For the one using the module, it's all pretty much
guesswork whether the author considered something major or minor functionality.
> After writing a couple of py progs, i find myself using the python way
> in Java, and i prefer it (used to write C progs this way 10 yrs ago), and
> i need some justification for this, since i am the guy who made the Java
> guidelines for my org 4 years back !
I use camelCase in method names, MixedCase for classes and objects, UPPERCASE
for 'constants' (well, things that are *supposed* to remain constant anyway),
lowercase for most variables and normal functions, while avoiding under_scores
like the plague :) - I find them very time consuming. In the end, I suppose it's
all a matter of taste, as long as it's consistent.
When I started programming in Pascal, we were taught to write "BEGIN". When I
switched to Delphi, which uses "begin" in all generated code, I found that
lowercase stuff quite annoying. Not too long ago I looked at an old Pascal
program and found the all-caps impossible to read again :).
--
Yours,
Andrei
=====
Mail address in header catches spam. Real contact info (decode with rot13):
cebwrpg5 at bcrenznvy.pbz. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur
yvfg, fb gurer'f ab arrq gb PP.
More information about the Tutor
mailing list