Re: [Tutor] inheritance problem

2010-10-01 Thread ALAN GAULD
> > OOP is a step up from functions its true but you need to work to > > understand it or you will continue to get confused by trivial errors. > > Then appearently I don't work hard enough. > Im still getting confuse by this example. > > I wrote this piece : > > def print_hands(self): >

Re: [Tutor] inheritance problem

2010-10-01 Thread Alan Gauld
"Roelof Wobben" wrote The cards are stored in a directory named cards. Correct. So how do you get a card from the collection stored in self.cards? This is not correct. Card is a list and not a directory. See this : self.cards = [] OK, if thats the mistake you made then you made two mis

Re: [Tutor] inheritance problem

2010-10-01 Thread Roelof Wobben
>>> >>> I assigned a card by this code : >>> >>> def deal(self, hands, num_cards=999): >>> num_hands = len(hands) >>> for i in range(num_cards): >>> if self.is_empty(): break # break if out of cards >>> card = self.pop() # take the top card >>> hand = hands[i % num_hands] # whose turn is next? >

Re: [Tutor] inheritance problem

2010-10-01 Thread Alan Gauld
"Roelof Wobben" wrote So if the code you copied has an error how should it assign a card? I assigned a card by this code : def deal(self, hands, num_cards=999): num_hands = len(hands) for i in range(num_cards): if self.is_empty(): break # break if out of cards card = self.pop() # take the t

Re: [Tutor] inheritance problem

2010-10-01 Thread Roelof Wobben
> From: rwob...@hotmail.com > To: alan.ga...@btinternet.com; tutor@python.org > Date: Fri, 1 Oct 2010 06:19:29 + > Subject: Re: [Tutor] inheritance problem > > > > > >> To:

Re: [Tutor] inheritance problem

2010-09-30 Thread Roelof Wobben
> To: tutor@python.org > From: alan.ga...@btinternet.com > Date: Fri, 1 Oct 2010 00:59:06 +0100 > Subject: Re: [Tutor] inheritance problem > > "Roelof Wobben" wrote > >> So i have this programm now : > >> cl

Re: [Tutor] inheritance problem

2010-09-30 Thread Alan Gauld
"Roelof Wobben" wrote So i have this programm now : class Deck: def __init__(self): self.cards = [] for suit in range(4): for rank in range(1, 14): self.cards.append(Card(suit, rank)) def deal(self, hands, num_cards=999): num_hands = len(

Re: [Tutor] inheritance problem

2010-09-30 Thread Joel Goldstick
I looked at the chapter before, and found this in particular: class Deck: def __init__(self): self.cards = [] for suit in range(4): for rank in range(1, 14): self.cards.append(Card(suit, rank)) I think the error in the book has to do with self.pop()

Re: [Tutor] inheritance problem

2010-09-30 Thread Albert-Jan Roskam
alth, what have the Romans ever done for us? ~~ From: Bob Gailer To: Roelof Wobben ; tutor@python.org Sent: Thu, September 30, 2010 9:12:48 PM Subject: Re: [Tutor] inheritance problem Sorry I hit the send button instead of the save button On Thu, Sep 30, 2010 at 2:58 PM, Bob Gailer wrote: >

Re: [Tutor] inheritance problem

2010-09-30 Thread Bob Gailer
Sorry I hit the send button instead of the save button On Thu, Sep 30, 2010 at 2:58 PM, Bob Gailer wrote: > On Thu, Sep 30, 2010 at 2:38 PM, Roelof Wobben wrote: >> >> hello, >> >> Im following this page : >> http://openbookproject.net/thinkcs/python/english2e/ch17.html >> >> [snip] >> >> What

Re: [Tutor] inheritance problem

2010-09-30 Thread Evert Rol
Hi Roelof, > Im following this page : > http://openbookproject.net/thinkcs/python/english2e/ch17.html I just checked this, and it appears you've copied this example fine. > class Deck: >def __init__(self): >self.cards = [] >for suit in range(4): >for rank in

[Tutor] inheritance problem

2010-09-30 Thread Roelof Wobben
hello, Im following this page : http://openbookproject.net/thinkcs/python/english2e/ch17.html So i have this programm now : class Card: suits = ["Clubs", "Diamonds", "Hearts", "Spades"] ranks = ["narf", "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen",