Re: [Tutor] modifying global within function without declaring global

2013-01-08 Thread Mitya Sirenef
On Tue 08 Jan 2013 08:07:57 PM EST, Alan Gauld wrote: On 05/01/13 01:27, Nathaniel Huston wrote: def deal(quantity): hand = [] for cards in range(0, quantity): hand.append(deck.pop()) return hand > #we find that the global deck has been modified within the deal() > fu

Re: [Tutor] modifying global within function without declaring global

2013-01-08 Thread Oscar Benjamin
On 9 January 2013 01:07, Alan Gauld wrote: > On 05/01/13 01:27, Nathaniel Huston wrote: > >> def deal(quantity): >> >> hand = [] >> for cards in range(0, quantity): >> hand.append(deck.pop()) >> return hand > > >> #we find that the global deck has been modified within the d

Re: [Tutor] modifying global within function without declaring global

2013-01-08 Thread Alan Gauld
On 05/01/13 01:27, Nathaniel Huston wrote: def deal(quantity): hand = [] for cards in range(0, quantity): hand.append(deck.pop()) return hand > #we find that the global deck has been modified within the deal() > function without including > > global deck > > #within th

[Tutor] modifying global within function without declaring global

2013-01-08 Thread Nathaniel Huston
As far as I understood, this shouldn't be possible. this is python 2.7 weirdness is in deal() at the end import random class card:     def __init__(self, suit, rank, name):     self.suit = suit     self.rank = rank     self.name =