Hungarian notation (was RE: variable naming...)

Jonathan Gilligan jonathan.no.spam.on.that.gilligan at vanderbilt.edu
Thu May 3 19:48:29 EDT 2001


"Greg Ewing" <see at my.signature> wrote in message
news:3AEF88BE.B7A0BC0C at my.signature...
> Hungarian taken to the extreme of distinguishing
> integers from floats, etc. is certainly pointless
> in most languages nowadays, especially Python.

This is manifestly not true. Suppose, as a previous writer on this thread
posits, I am writing a class that describes spatial coordinates. First I
think I will use integers to describe the coordinates and I check for
collisions using ==. Later I decide that I must use floating point numbers.
Now I must go through the code and replace exact equality testing with
"abs(x1 - x2) < epsilon". Even in Python, integers and floats are distinct
and must be considered differently. Similarly, if I am changing floats to
integers, I must be careful with expressions such as

foo = x / y
...
bar = foo * z

If x = 3 and  z = 8, I get quite different results for y = 4 and y = 4.0.

If I am using Hungarian notation, the exercise of changing variable names
(not just doing a global search and replace) is a good time to catch such
problems and fix them.





More information about the Python-list mailing list