Danny Yoo wrote: > > >> I have attached what I got so far if you feel like taking a look, but >> it is probably nasty by your standards :) > > Good, this is exactly what I want. Yes, there are a few things here > that you will want to learn how to fix. Let me point out one or two, > and I'm sure others here on the list can chime in too. > > ##################################### > ## within definition of char_sheet(): > > if month == 1: > month = "January" > elif month == 2: > month = "February" > elif month == 3: > month = "March" > ... > ##################################### > > Make this a separate function: the essence of this block of code is > pretty self-contained as a number-to-month-string converter. I never thought about that, I will put it into its own function. That makes sense because I may actually need to use that number-month converter in another part of the program.
> There is also a much nicer way to express the code: rather than make it > conditional logic, just build a data structure that naturally expresses > the mapping from a number to a string. There are two data structures > that fit the above nicely: a "list" and a "hashtable". For the above, a > list naturally works out. > > ###################################### > ## pseudocode > months = ["January", "February", ...] > monthName = months[monthNumeral - 1] > ###################################### > > Do this, and that block of code reduces from twenty-four lines to about > three. Thanks, that is a great idea. Also, this will be a good exercise for me to learn about list. > I'm looking at the number of attributes you're storing as a Player. Yea, both Pychecker and pylint complained about that. > All these values "belong" together. Rather than pass them separately, > glue them together as a "structure". In Python, can we use a class to > glue things together... Okay, that makes good sense :) This should be a good exercise for OOP Programming :) > There are a few other things to discuss about in the code, but I should > let you take a look again and respond before going on. If you have more > questions, please feel free to ask the list. Thanks, I never even expected you to go through the code :) I will work at your suggestions and will get back to you if I have any problems. -- Your friend, Scott Sent to you from a Linux computer using Kubuntu Version 7.04 (Feisty Fawn) _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor