[Tutor] Is there an easily or shorter way?

Dave Angel davea at davea.name
Tue Dec 16 04:50:59 CET 2014

On 12/15/2014 07:55 PM, Ken G. wrote:
> Oh, it is not an assignment, Dave. It is an actual program I am using
> for my benefit. I had to figure out on a fly, what is the name of a piece
> of property that each number represent. I had to reckon something out
> within a limited amount of time I had. Giving the response given here
> so far, I could go with a list, dictionary or tuple.

Two other advantages with using a tuple, list or dictionary

1) is that you might someday need to do the reverse lookup, changing a 
string back into the integer.  If you do it from the same data 
structure, you're more likely to get the transformation to be completely 
reversible (for valid values).

2) You might need to load this table from a file, or otherwise generate 
or check it on the fly.  Tough to do that with separate function statements.


More information about the Tutor mailing list