Re: [Pyparsing] Strategies for use with ParseFile
Brought to you by:
ptmcg
From: Paul M. <pt...@au...> - 2008-01-23 15:41:28
|
David - The naming schemes go like this (cf. http://www.python.org/dev/peps/pep-0008/, under "Naming Conventions"): __xxx__ : "magic" methods useful by convention by Python internals. Examples include __init__, __call__, __add__, __del__, __dict__ (pyparsing uses methods like these __add__, __or__, __xor__, etc. to do the operator overloading) _xxx : quasi-private names, these do not get imported when using "from module import *" xxx_ : convention for naming variables that conflict with Python keywords (class_, for_, etc.) __xxx : class attributes with leading double-underscore are name-mangled by the Python interpreter to "hide" them externally, a form of private but can be worked around if you really, really, really need to (reference __xxx in class Y as _Y__xxx, but to my mind, this is even a worse red flag than using an attribute with a leading underscore). As you've probably noticed, pyparsing doesn't fully comply with PEP8, mostly with respect to using camel case names instead of names_with_underscores. I think it is just my own personal history - I used to use names with underscores back in my C and PL/I days, and then "graduated" to mixed case when I moved to Smalltalk, C++ and Java. And I'm glad you were able to make some sense of my ramblings. :) -- Paul |