[Tutor] class question

Corey Richardson kb1pkl at aim.com
Wed Jan 26 04:14:02 CET 2011


On 01/25/2011 08:50 PM, Steven D'Aprano wrote:
> Corey Richardson wrote:
>> On 01/25/2011 06:26 PM, Elwin Estle wrote:
>>> Is it better to have one large sort of "do it all" class, or break
>>> the larger class up into smaller classes?
> 
>> If you're just learning, go ahead and make a 'do it all' class. Don't do
>> it later in your growth as a programmer though.
> 
> Learn bad habits first, then spend years trying to break them!
> 
> *wink*


Hey, gotta learn the concepts first, right? ;-)
I remember my first "substantial" program, hangman! Quite a mess.
Excerpt:

    def getlist3(self):
        list3 = []
        for i in range(5):
            list3.append(self.gameWord[i])
        self.list3 = list3

I don't even remember what list3 is. I have a whole function for a list
comprehension!

self.list3 = [char for (idx, char) in enumerate(gameWord) if
              gameWord.index(char, idx) < 5]

(list3 happened to be the hint characters given, remembered while doing)

Just proof that it doesn't have to take years, it could take months.


More information about the Tutor mailing list