classes vs dicts
Heather Coppersmith
me at privacy.net
Thu May 6 07:22:05 EDT 2004
On 6 May 2004 03:12:15 -0700,
charlvj at yahoo.com (Charlie) wrote:
> Say I want to write an address book program, what is the best
> way to define a person (and the like): create a class (as I
> would do in Java) or use a dictionary?
> I guess using dictionaries is fastest and easiest, but is this
> recommended?
In the end (and in the implementation), classes are just syntactic
sugar for dictionaries.
object.attribute is equiv. to dictionary[ 'key' ]
"Faster" is probably not applicable unless you're doing thousands
of lookups (designing and coding times should be about the same).
"Easiest" is a matter of personal taste.
HTH,
Heather
--
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli
More information about the Python-list
mailing list