Re: [Tutor] Variables and Functions

2007-11-30 Thread Ricardo Aráoz
Alan Gauld wrote: > "Devon MacIntyre" <[EMAIL PROTECTED]> wrote > >> input their own numbers to fill in the board. My problem is that I >> can't get >> the variables 'puzzle' and 'new_puzzle' into that function (to be >> compared) >> because they are not globally defined; only in 'new_sudoku' >

Re: [Tutor] Variables and Functions

2007-11-29 Thread Alan Gauld
"Devon MacIntyre" <[EMAIL PROTECTED]> wrote > input their own numbers to fill in the board. My problem is that I > can't get > the variables 'puzzle' and 'new_puzzle' into that function (to be > compared) > because they are not globally defined; only in 'new_sudoku' > function. Here's > some se

Re: [Tutor] Variables and Functions

2007-11-28 Thread Michael H. Goldwasser
Hello Devon, Here's a quick [untested] push in the direction of taking the code you gave below and modeling it as a class using an object-oriented design. With this code, you could then create an instance of a puzzle as: toughOne = Sudoku() toughOne.play_game() Within

Re: [Tutor] Variables and Functions

2007-11-28 Thread Tiger12506
when we say you can put all of your functions in a class and use a class variable (in this case... self.puzzle) - Original Message - From: "Devon MacIntyre" <[EMAIL PROTECTED]> To: "Kent Johnson" <[EMAIL PROTECTED]> Cc: Sent: Wednesday, November 28, 20

Re: [Tutor] Variables and Functions

2007-11-28 Thread Devon MacIntyre
Hi, I have two functions, 'new_sudoku' and 'play_game'. In new_sudoku, I have a pre-determined puzzle (I wasn't able to get a randomly generated puzzle working), as a matrix in the variable 'puzzle'. I imported the 'copy' module and made a deep-copy of 'puzzle' to make 'new_puzzle', which randomly

Re: [Tutor] Variables and Functions

2007-11-28 Thread Alan Gauld
"Devon MacIntyre" <[EMAIL PROTECTED]> wrote > Just wondering, how would I get a variable out of one function and > into > another? return the value from one function and pass it as an argument to the other. Example: def oneFunction() x = [1,2,3] return x def another(aValue): pr

Re: [Tutor] Variables and Functions

2007-11-28 Thread Kent Johnson
Devon MacIntyre wrote: > Hi, > Just wondering, how would I get a variable out of one function and into > another? I don't understand your description of your situation, maybe you could show a little code as a simple example? The usual way to get a variable out of a function is to return a valu

Re: [Tutor] Variables and Functions

2007-11-28 Thread Tiger12506
Subject: [Tutor] Variables and Functions > Hi, > Just wondering, how would I get a variable out of one function and into > another? I'm trying to make a Sudoku puzzle for Python 2.5.1, and in one > function I have the finished puzzle (as a matrix) called 'puzzle'. Usi

[Tutor] Variables and Functions

2007-11-28 Thread Devon MacIntyre
Hi, Just wondering, how would I get a variable out of one function and into another? I'm trying to make a Sudoku puzzle for Python 2.5.1, and in one function I have the finished puzzle (as a matrix) called 'puzzle'. Using the 'copy' module I made a deep copy called 'new_puzzle'. That function is ca