Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Naming conventions for regular variables

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


mrkafk at gmail

Jul 4, 2008, 3:59 AM

Post #1 of 2 (111 views)
Permalink
Naming conventions for regular variables

http://www.python.org/dev/peps/pep-0008/

"Function Names

Function names should be lowercase, with words separated by underscores
as necessary to improve readability."

However, this PEP does not recommend any particular style for naming
regular (local) variables.

Personally I like "mixedCase", however using both styles looks a bit weird:

def some_function_name(someVariableName, anotherVar)

Naming both functions and variables using "lowercase with underscore
separator between words for readability" leads to confusing function
names with variable names - and distinguishing between variables and
function names just by looking at them would be nice.

Recommendations?





--
http://mail.python.org/mailman/listinfo/python-list


bignose+hates-spam at benfinney

Jul 4, 2008, 4:51 AM

Post #2 of 2 (77 views)
Permalink
Re: Naming conventions for regular variables [In reply to]

mk <mrkafk [at] gmail> writes:

> http://www.python.org/dev/peps/pep-0008/
>
> "Function Names
>
> Function names should be lowercase, with words separated by
> underscores as necessary to improve readability."
>
> However, this PEP does not recommend any particular style for naming
> regular (local) variables.

Yes, it does: "Method Names and Instance Variables" applies. Any
object that isn't a class is an "instance", to be named according to
that section.

> Personally I like "mixedCase"

Nothing in PEP 8 allows mixedCase (except for the rare degenerate case
where you're constrained to closely follow an existing naming
convention). It's always TitleCase or lowercase, with or without
underscores.

> Naming both functions and variables using "lowercase with underscore
> separator between words for readability" leads to confusing function
> names with variable names - and distinguishing between variables and
> function names just by looking at them would be nice.

Functions are first-class objects in Python, and many non-function
objects are callable. So, such an arbitrary distinction wouldn't be
helpful.

It's more sensible to distinguish by *usage*: is it being called or
not?

> Recommendations?

Follow PEP 8, including the avoidance of mixedCase.

--
\ “I went to a general store. They wouldn't let me buy anything |
`\ specifically.” —Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.