variable naming...

Ben Hutchings ben.hutchings at roundpoint.com
Thu Apr 26 17:23:32 EDT 2001


ransen_spam_me_not at nemo.it (Owen F. Ransen) writes:

> Gonna get a lot of flames for this one maybe...
> 
> In C I am used to using the notation where the first bit
> of the name tells you the type of the variable:
> 
> int iNumFlames ;  // integer
> char szFlame[MAX_CHARS] ; // zero terminated string

This is called Hungarian notation, after the country of origin of its
inventor Charles Simonyi.  It is meant to encode the abstract type of
a variable (what the variable is meant to be used for), not concrete
type information (what language-supported type is being used), though
in practice his colleagues at Microsoft seem to have used it for the
latter.

> and so on. I presume this is not reccommended in Python?

I've never seen it used in Python.

> I've found it very helpful in C...

In C there's little to stop you making meaningless type conversions by
accident, and all local variables have to be declared at the top of
the block, so it may be useful to keep reminding the reader of the
types of variables.  Most other languages don't have this problem.

> Is there an "official" or "semi-official" style, like when
> to use lowercase and uppercase and mixed?

See the Python Style Guide:
<http://www.python.org/doc/essays/styleguide.html#names>.

-- 
Any opinions expressed are my own and not necessarily those of Roundpoint.



More information about the Python-list mailing list