[Tutor] Function returns 'None'

2010-07-11 Thread Dominik Danter
Hello As en exercise I wrote the following function: def recursfac(x,carryover=1): print 'x:',x,'carryover:', carryover if x > 1: carryover *= x recursfac(x-1, carryover) else: return carryover print recursfac(3) Very much to my surprise I get the following

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Adam Bark
On 11/07/10 14:59, Dominik Danter wrote: Hello As en exercise I wrote the following function: def recursfac(x,carryover=1): print 'x:',x,'carryover:', carryover if x > 1: carryover *= x recursfac(x-1, carryover) else: return carryover print recursfac(3) Ve

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Alan Gauld
"Dominik Danter" wrote def recursfac(x,carryover=1): print 'x:',x,'carryover:', carryover if x > 1: carryover *= x recursfac(x-1, carryover) No return value here so when the reursed function returns carryover we have nowhere to go in the calling function so we return

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Nick Raptis
On 07/11/2010 04:59 PM, Dominik Danter wrote: Hello As en exercise I wrote the following function: def recursfac(x,carryover=1): print 'x:',x,'carryover:', carryover if x > 1: carryover *= x recursfac(x-1, carryover) else: return carryover print recursfac(3

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Nick Raptis
On 07/11/2010 06:28 PM, Nick Raptis wrote: def recursfac(x,carryover=1): print 'x:',x,'carryover:', carryover if x > 1: carryover *= x carryover = recursfac(x-1, carryover) return carryover And this returns x: 3 carryover: 1 x: 2 carryover: 3 x: 1 carryover: 6 6 Don

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Luke Paireepinart
I think the new version is harder to understand. Sent from my iPhone On Jul 11, 2010, at 10:43 AM, Nick Raptis wrote: > On 07/11/2010 06:28 PM, Nick Raptis wrote: >> >> def recursfac(x,carryover=1): >>print 'x:',x,'carryover:', carryover >>if x > 1: >>carryover *= x >>c

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Nick Raptis
On 07/11/2010 06:50 PM, Luke Paireepinart wrote: I think the new version is harder to understand. Sent from my iPhone On Jul 11, 2010, at 10:43 AM, Nick Raptis wrote: Aww! A critic! You humble me (really, I'm not being sarcastic here, I welcome it gladly) I won't argue about it, though. If

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Luke Paireepinart
On Jul 11, 2010, at 11:14 AM, Nick Raptis wrote: >> >> >> > > Also, another preference of mine, would you be kind enough to answer to the > list and cc the original poster if you can? Doing it the other way around > breaks my (quite stupid I admit) filters, and perhaps others' too. That's t

[Tutor] Path?

2010-07-11 Thread Jim Byrnes
I am running Ubuntu. I downloaded the source code examples for a book I purchased. Some of the examples load image files located in the same directory as the program. If I go to the current directory in the terminal the program can use the image files. However, if I use a launcher or the fi

Re: [Tutor] feedback on permutations script

2010-07-11 Thread Isaac
> On Sun, 11 Jul 2010 02:48:38 am Isaac wrote: > >* This is my interpretation of an algorithm to generate all *> >* permutations of items in a list. I would appreciate any feedback *> >* regarding advice for improvements. **> Steven D'Aprano* wrote: *Sun Jul 11 05:29:58 CEST 2010* > Some of thi

Re: [Tutor] Path?

2010-07-11 Thread Adam Bark
On 11/07/10 18:42, Jim Byrnes wrote: I am running Ubuntu. I downloaded the source code examples for a book I purchased. Some of the examples load image files located in the same directory as the program. If I go to the current directory in the terminal the program can use the image files. H

[Tutor] extract a submatrix

2010-07-11 Thread Bala subramanian
Friends, Excuse me if this question is not appropriate for this forum. I have a matrix of size 550,550. I want to extract only part of this matrix say first 330 elements, i dnt need the last 220 elements in the matrix. is there any function in numpy that can do this kind of extraction. I am quite n

Re: [Tutor] Path?

2010-07-11 Thread Steven D'Aprano
On Mon, 12 Jul 2010 03:42:28 am Jim Byrnes wrote: > I am running Ubuntu. I downloaded the source code examples for a > book I purchased. Some of the examples load image files located in > the same directory as the program. If I go to the current directory > in the terminal the program can use th