Sorry I hit the send button instead of the save button On Thu, Sep 30, 2010 at 2:58 PM, Bob Gailer <bgai...@gmail.com> wrote: > On Thu, Sep 30, 2010 at 2:38 PM, Roelof Wobben <rwob...@hotmail.com> wrote: >> >> hello, >> >> Im following this page : >> http://openbookproject.net/thinkcs/python/english2e/ch17.html >> >> [snip] >> >> What went wrong here. > IMHO you are tackling a very large program while still not getting Python basics and still not walking through the program
I once again am weary of holding your hand. I suggest (again) that you walk through the program BY HAND step by step, analyzing and understanding what happens at each step. There are so many problems in your code even if I told you exactly what's wrong you will just get the next error-or-unexpected result then the next, and so on. I will start you: game = CardGame() # leads to class CardGame: def __init__(self): self.deck = Deck() #leads to class Deck: def __init__(self): self.cards = [] # an empty list is bound to the instance attribute "cards" for suit in range(4): for rank in range(1, 14): self.cards.append(Card(suit, rank)) # one-by-one Card instances are appended to self.cards #leads to class Card: suits = ["Clubs", "Diamonds", "Hearts", "Spades"] # a list of suit names is bound to class attribute suits ranks = ["narf", "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"] # a list of rank names is bound to class attribute ranks def __init__(self, suit=0, rank=0): self.suit = suit # the suit number passed as an argument is bound to the Card instance suit self.rank = rank # the rank number passed as an argument is bound to the Card instance rank # the result is a Card instance with two attributes, suit and rank. And so forth. Laborious? Time consuming? Lots of detail? Yes. Most of us have gone thru the same thing in our education. Regarding the error: AttributeError: Deck instance has no attribute 'pop' You should be able by now to know what that means and why it is happening. A lot of us on this list are spending a lot of time "helping" you. I for one again am imploring you to spend more time gaining understanding and asking us for less help of this nature. Others may disagree - that is my opinion. -- Bob Gailer 919-636-4239 _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor