Re: [Tutor] self.name vs. passing a name

2009-07-28 Thread Che M
> > The "answer" to each function is then used in the next function. > > I can think of two ways to make that answer available ... > > 1) pass it in, or > > 2) declare it as self.answer Thank you Alan, Kent, and Dave. Full agreement, and it makes sense to me. (Maybe this is also an example

Re: [Tutor] self.name vs. passing a name

2009-07-28 Thread Dave Angel
Che M wrote: This is another very basic structural question, related to one I asked last week, and again is not necessarily germane only to Python. Let's say you have a sequence of two calculations or manipulations you need to do, each one done as a function called by an overall calculate_some

Re: [Tutor] self.name vs. passing a name

2009-07-28 Thread Alan Gauld
"Che M" wrote Let's say you have a sequence of two calculations ...each one done as a function called by an overall calculate_something() function. The "answer" to each function is then used in the next function. I can think of two ways to make that answer available ... 1) pass it in, or

Re: [Tutor] self.name vs. passing a name

2009-07-27 Thread Kent Johnson
On Mon, Jul 27, 2009 at 7:39 PM, Che M wrote: > 1.Pass the variable to the second function. > > def calculate_something(self): >     answer = self.do_first_calculation()    #1st function returns answer >     self.do_second_calculation(answer)    #2nd is passed answer and uses it. > > 2. Create the