Re: tutorial example?????

2005-11-13 Thread Brian van den Broek
john boy said unto the world upon 2005-11-12 19:43: > OK...I have the following program > > i = 1 > while i <= 6: > print 2 * i,' ', > i = i + 1 > print > > this is supposed to give you a "new" blank line after the program runs > instead it just gives: > 2 4 6 8 10 12 > >

Re: tutorial example

2005-11-12 Thread Steven D'Aprano
On Sat, 12 Nov 2005 13:42:37 +, Max Erickson wrote: > > Not in python. > > For example, what would you call the following? > > def rsum(n, m): > print n+m > return n+m > > > In python a method is callable attached to an object. A function is a > callable object constructed with a

Re: tutorial example

2005-11-12 Thread Colin J. Williams
Max Erickson wrote: > Not in python. > > For example, what would you call the following? > > def rsum(n, m): > print n+m > return n+m > I would call it a python function with a side-effect. Colin W. > > In python a method is callable attached to an object. A function is a > callable o

Re: tutorial example

2005-11-12 Thread Roel Schroeven
Ruben Charles wrote: > That is the diference between a method and a function. > A method do something and a function return something. I'd rather say it's the difference between a procedure and a function, as it is used in e.g. Pascal. Procedures in Pascal don't return anything, more or less analo

Re: tutorial example

2005-11-12 Thread Colin J. Williams
Ruben Charles wrote: > That is the diference between a method and a function. > A method do something and a function return something. > This is not quite correct. The difference between a method and a function is that the method is associated with a type or class object, a function is not. A m

Re: tutorial example

2005-11-12 Thread Ruben Charles
On 11/12/05, Max Erickson <[EMAIL PROTECTED]> wrote: > > Not in python. > > For example, what would you call the following? > > def rsum(n, m): > print n+m > return n+m > > > In python a method is callable attached to an object. A function is a > callable object constructed with a def state

Re: tutorial example

2005-11-12 Thread Max Erickson
Not in python. For example, what would you call the following? def rsum(n, m): print n+m return n+m In python a method is callable attached to an object. A function is a callable object constructed with a def statement. max -- http://mail.python.org/mailman/listinfo/python-list

Re: tutorial example

2005-11-12 Thread Ruben Charles
That is the diference between a method and a function. A method do something and a function return something. Example: def psum(n, m): print (n + m) def rsum(n, m): return (n +m) Then try this... >>> psum(2, 3) >>> a = psum(2, 3) >>> a >>> a = rsum(2, 3) >>> a You see it? -- ht

Re: tutorial example

2005-11-11 Thread Max Erickson
>>> import math >>> def distance1(x1, y1, x2, y2): dx = x2 - x1 dy = y2 - y1 dsquared = dx**2 + dy**2 result = math.sqrt(dsquared) print result return result >>> def distance2(x1, y1, x2, y2): dx = x2 - x1 dy = y2 - y1 dsquared = dx**2 + dy**2 result = math.s