steven.bethard at gmail.com
Mon Aug 29 01:53:28 CEST 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" doesn't mean that something is actually wrong,
just that it might be. In Python, pairs are usually handled with
tuples, 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. ;-)
More information about the Python-list