Do I always have to write "self." ?

Dave Abrahams abrahams at mediaone.net
Sun Apr 30 20:02:44 EDT 2000


in article slrn8gp7ei.ilf.kc5tja at garnet.armored.net, Samuel A. Falvo II at
kc5tja at garnet.armored.net wrote on 4/30/00 9:03 AM:

> If it's a dict, or if it's a UserDict, or if it's anything else that exports
> the dict interface, then it's perfectly valid to name a parameter
> dictWhatever.  I fail to see what's wrong with this concept.

As Simonyi, the author of the Hungarian notation concept writes, "the basic
idea is to name all quantities by their types". If you are naming quantities
by their interface, you are taking a step away from Hungarian. Do as I do,
naming quantities by their *role*, and you have taken a long leap away from
Hungarian.

I can see how it might help to name a variable by its interface, especially
in Python if you don't write comments. But: do you write listDogs, tupleDogs
or sequenceDogs when you're being passed a sequence of dogs? Don't the
prefix nouns start to sound a bit like adjectives? Or do you come up with
some tongue-twisting acronym for each of these?

Suppose you're writing UserDict. What do you name your function arguments
which represent keys and values? Not too many requirements on the value
type, are there? Is Hungarian applied only selectively?

and-is-my-name-person-dave-or-programmer-dave-ly y'rs,
-pDave




More information about the Python-list mailing list