Newbie Question: Naming Conventions

Rainy sill at optonline.net
Sat Jun 16 23:37:01 EDT 2001


On 16 Jun 2001 00:39:01 -0700, Abe <awhite at techtrader.com> wrote:
> I expect that this is a subject that has been beaten to death, but I
> haven't been able to find much info on it:
> 
> I've experimented with many many computer languages, and I have to say
> that from what I've seen thus far of Python, it is probably the most
> elegant I've encountered.  The combination of its clean syntax, OO
> nature, and functional aspects is excellent.  HOWEVER, I'm very
> frustrated over the apparent lack of stylistic conventions for method
> names, etc in an otherwise consistent language.
> 
> From a search of the archives, it appears that Guido's stance on this
> is that developers should be free to choose a style that suits them. 
> I don't think anyone would disagree with that, but can't we at least
> have some consistency for the standard packages and built in
> functions?  The recent trend seems to be towards CapitalWords for
> classes and alllowercase for methods and packages... but then there
> are builtin throwbacks like has_key and raw_input mixed in that stick
> out like a sore thumb.

I think the idea is that really often-used names are lower case because
they'd be hard to type if they weren't, and rarely used ones like
say UserDict are upper case. If you add that rule, it makes sense,
I think.

> 
> Coming from the java world where the naming style is very consistent,
> having to use 'has_key' in the same code block as 'hasattr' drives me
> crazy!  I could easily modify the C files to alias the 'haskey' and
> 'rawinput' names to the correct methods, but then my code wouldn't
> work on any other python runtime.

Yeah, that's true.. I'm not sure why has_key is different from hasattr,
maybe somebody else can fill this one in..

> 
> So my question is: is there any proposal to standardize this sort of
> thing?  Would such an initiative be welcome in the python community,
> or is it seen as not important?  Does anyone see any obvious
> compatibility problems with providing an extra 'correct' version of
> nonconforming methods and classes until the originals can eventually
> be phased out?
> 
> Or if this has all been covered before, please let me know where I can
> find the relevant discussion.
> 
> Thanks!


-- 
Delay not, Caesar.  Read it instantly.
                -- Shakespeare, "Julius Caesar" 3,1
Here is a letter, read it at your leisure.
                -- Shakespeare, "Merchant of Venice" 5,1
        [Quoted in "VMS Internals and Data Structures", V4.4, when
         referring to I/O system services.]



More information about the Python-list mailing list