trictionary?
Steven Bethard
steven.bethard at gmail.com
Sun Aug 28 19:53:28 EDT 2005
Adam Tomjack wrote:
> Steven Bethard wrote:
> ...
>> Using a two element list to store a pair of counts has a bad code
>> smell to me.
> ...
>
> Why is that?
Note that "code smell"[1] doesn't mean that something is actually wrong,
just that it might be. In Python, pairs are usually handled with
tuples[2], but tuples would be inconvenient in this case, since the
first value must be modified. Declaring a class with two attributes as
you suggested is often a good substitute, but if the OP's code is really
what it looks like, I get another code smell because declaring a class
to be used by only 10 lines of code seems like overkill.
I also get a code smell from a dict holding two-element lists because
I've been writing in Python and answering questions on the Python-list
for a couple of years now, and I've never needed one yet. ;-)
STeVe
[1]http://en.wikipedia.org/wiki/Code_smell
[2]http://www.python.org/doc/faq/general.html#why-are-there-separate-tuple-and-list-data-types
More information about the Python-list
mailing list