Coding standard: Prefixing variables to indicate datatype

Erik Max Francis max at alcyone.com
Thu Jan 16 05:30:37 EST 2003


Thomas Weholt wrote:

> In my day-job I use Delphi/Object Pascal. My firm has a
> coding-standard
> where we prefix all variables with a single character to indicate
> datatype;
> strings are prefixed with s, integers with i, floats with f etc. etc.

This general class of notation is called Hungarian notation.  It's
either strongly liked or disliked; there's rarely opinions that lie in
between.  (I'm of the opinion that it is almost always overkill, tends
to become inaccurate over time due to code shift, and 99% of its
benefits can be gained simply by choosing appropriate identifiers.  Not
to mention terrribly ugly.)

> Are there any standards like this for Python? Or hints, tips, opinions
> related to this topic? I do believe it could make source more
> understandable
> and easier to debug/maintain when used in larger projects.

In dynamic languages, a Hungarian notation coding style makes even less
sense:  As long as an object supports the expected interface, it really
doesn't make any difference what type it is; furthermore, names can be
rebound to objects of completely different types, so associating the
type with the name is even less appealing.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Nine worlds I remember.
\__/ Icelandic Edda of Snorri Sturluson
    Blackgirl International / http://www.blackgirl.org/
 The Internet resource for black women.




More information about the Python-list mailing list