Bring object 'out of' Class?

member thudfoo thudfoo at opensuse.us
Sun Jun 1 18:14:28 CEST 2008


On 6/1/08, Arnaud Delobelle <arnodel at googlemail.com> wrote:
> dave <squareswallower at 1ya2hoo3.net> writes:
>
[..]

>  >
>  >    def deal_cards(self, num_of_hands, num):
>  >        '''deals x amount of cards(num) to each hand'''
>  >        for i in range(num_of_hands):
>  >            handname = Hand('hand%d' % i)
>  >            self.deal(handname, num)
>  >            print '::::%s::::' % (handname.label), '\n', handname, '\n'
>  >
>
>
> You need to use a 'return' statement:
>
>
>    def deal_cards(self, num_of_hands, num):
>        '''deals x amount of cards(num) to each hand'''
>
>        hands = []
>
>        for i in range(num_of_hands):
>
>            newhand = Hand('hand%d' % i)
>            self.deal(newhand, num)
>            hands.append(newhand)
>
>            print '::::%s::::' % (handname.label), '\n', handname, '\n'
>
>        return Hand

Should be: return hands

>
>
>  Then you can write:
>
>  >>> hands = deck.deal_cards(4, 5) # On fait une belotte?
>
[...]



More information about the Python-list mailing list