On 18/06/18 23:12, Roger Lea Scherer wrote:
> My foggy understanding of recursion is probably the reason I can't figure
> this out. When turtle draws this program there is an orange line in the
> green which I would prefer not to have. I've tried all I could think of,
> but can't get the orange lin
My foggy understanding of recursion is probably the reason I can't figure
this out. When turtle draws this program there is an orange line in the
green which I would prefer not to have. I've tried all I could think of,
but can't get the orange line to go away, or maybe more accurately, not to
be dr
On 14/06/18 19:32, Daniel Bosah wrote:
I am trying to modify code from a web crawler to scrape for keywords from
certain websites. However, Im trying to run the web crawler before I
modify it, and I'm running into issues.
When I ran this code -
*import threading*
*from Queue import Queue*
*
On Thu, Jun 14, 2018 at 02:32:46PM -0400, Daniel Bosah wrote:
> I am trying to modify code from a web crawler to scrape for keywords from
> certain websites. However, Im trying to run the web crawler before I
> modify it, and I'm running into issues.
>
> When I ran this code -
[snip enormous co
I am trying to modify code from a web crawler to scrape for keywords from
certain websites. However, Im trying to run the web crawler before I
modify it, and I'm running into issues.
When I ran this code -
*import threading*
*from Queue import Queue*
*from spider import Spider*
*from domain i
Alan Gauld via Tutor wrote:
> On 23/05/17 06:18, Peter Otten wrote:
>> Michael C wrote:
>>
>>> oh ya, my function does in fact take no input and doesn't change
>>> anything, and all i wanted to was to call itself a 2nd time, yes, so I
>>> solved it a few hours back ,and it's good enough for me fo
On 23/05/17 06:18, Peter Otten wrote:
> Michael C wrote:
>
>> oh ya, my function does in fact take no input and doesn't change anything,
>> and all i wanted to was to call itself a 2nd time, yes, so I solved it a
>> few hours back ,and it's good enough for me for now :)
>
> Would you mind showing
no i don't have a way, it just hasn't happened yet LOL
On Mon, May 22, 2017 at 10:18 PM, Peter Otten <__pete...@web.de> wrote:
> Michael C wrote:
>
> > oh ya, my function does in fact take no input and doesn't change
> anything,
> > and all i wanted to was to call itself a 2nd time, yes, so I so
Michael C wrote:
> oh ya, my function does in fact take no input and doesn't change anything,
> and all i wanted to was to call itself a 2nd time, yes, so I solved it a
> few hours back ,and it's good enough for me for now :)
Would you mind showing the code? I'd like to see how you avoid infinite
hi all:
oh ya, my function does in fact take no input and doesn't change anything,
and all i wanted to was to call itself a 2nd time, yes, so I solved it a
few hours back ,and it's good enough for me for now :)
Thanks for the response!!!
On Mon, May 22, 2017 at 2:16 PM, Alan Gauld via Tutor
wro
On 22/05/17 17:11, Michael C wrote:
> I have a function to return (x,y) value, but sometimes it would naturally
> unable to return those 2 values properly. I know what recursion is, and I
> think all I got to do is to call this function a 2nd time and the problem
> would go away.
Sorry, but that
hi all:
I have a function to return (x,y) value, but sometimes it would naturally
unable to return those 2 values properly. I know what recursion is, and I
think all I got to do is to call this function a 2nd time and the problem
would go away.
How do I do recursion? The function basically look l
On Thu, Feb 4, 2016 at 6:03 PM, noopy via Tutor wrote:
> Hi,
>
> I just cannot get my head around the following code, maybe someone could
> explain it to me.
One thing to note: the function here is a generator, which is itself
an intermediate subject that's specific to Python. Recursion is a
mor
On Feb 5, 2016 12:07 AM, "noopy via Tutor" wrote:
>
> Hi,
>
> I just cannot get my head around the following code, maybe someone could
explain it to me.
>
> def permutations(items):
When trying to understand a function (or in this case, a generator),
knowing the types of input and output can be h
Ben Finney wrote:
> Alan Gauld writes:
>
>> On 05/02/16 02:03, noopy via Tutor wrote:
>>
>> > def permutations(items):
>> > n = len(items)
>> > if n==0: yield []
>> > else:
>>
>> I assume this bit is clear enough?
>
> I think it would be clearer without the needless opaque name ‘
Alan Gauld writes:
> On 05/02/16 02:03, noopy via Tutor wrote:
>
> > def permutations(items):
> > n = len(items)
> > if n==0: yield []
> > else:
>
> I assume this bit is clear enough?
I think it would be clearer without the needless opaque name ‘n’.
Better::
def permutations(
On 05/02/16 02:03, noopy via Tutor wrote:
> I just cannot get my head around the following code, maybe someone could
> explain it to me.
I'll try but it is a little bit tricky.
> def permutations(items):
> n = len(items)
> if n==0: yield []
> else:
I assume this bit is clear eno
noopy via Tutor writes:
> But when "for cc in permutations([])" yields an empty list, why does
> "for cc in permutations("Z")" then actually have an item so that
> "yield [items[i]]+cc" will be executed?
Does this help::
>>> i = 1
>>> "Z"[:i] + "Z"[i+1:]
'Z'
Can you explain why tha
Hi,
I just cannot get my head around the following code, maybe someone could
explain it to me.
def permutations(items):
n = len(items)
if n==0: yield []
else:
for i in range(len(items)):
for cc in permutations(items[:i]+items[i+1:]):
yield [items
On Thu, 9 Jan 2014 13:02:30 -0500, Keith Winston
wrote:
Well, hopefully this is plain text. It all looks the same to me, so
if
gmail switches back, it might go unnoticed for a while. Sorry for
the
incessant hassle.
That looks great, thanks.
--
DaveA
_
On Thu, Jan 9, 2014 at 5:41 AM, Steven D'Aprano wrote:
>
> Keith, if you are able, and would be so kind, you'll help solve this
> issue for Dave if you configure your mail client to turn so-called "rich
> text" or formatted text off, at least for this mailing list.
Well, hopefully this is plain t
On Thu, 9 Jan 2014 21:41:41 +1100, Steven D'Aprano
wrote:
I presume that your question is aimed at Keith.
Yes, Keith's emails have a HTML part and a text part. A half-decent
mail
client should be able to read the text part even if the HTML part
exists. But I believe you're reading this fro
On Wed, Jan 08, 2014 at 06:16:03PM -0500, Dave Angel wrote:
> On Wed, 8 Jan 2014 16:23:06 -0500, eryksun wrote:
> >On Wed, Jan 8, 2014 at 3:25 PM, Keith Winston
> wrote:
> >> I've been playing with recursion, it's very satisfying.
> >>
> >> However, it appears that even if I sys.setrecursionlimi
On Wed, Jan 8, 2014 at 6:16 PM, Dave Angel wrote:
> I can't see the bodies of any of your messages (are you perchance posting
> in html? ), but I think there's a good chance you're abusing recursion and
> therefore hitting the limit much sooner than necessary. I've seen some code
> samples here
On Wed, 8 Jan 2014 16:23:06 -0500, eryksun wrote:
On Wed, Jan 8, 2014 at 3:25 PM, Keith Winston
wrote:
> I've been playing with recursion, it's very satisfying.
>
> However, it appears that even if I sys.setrecursionlimit(10),
it blows
> up at about 24,000 (appears to reset IDLE). I gue
On Wed, Jan 8, 2014 at 5:15 PM, spir wrote:
> Funny and useful exercise in recursion: write a func that builds str and
> repr expressions of any object, whatever its attributes, inductively. Eg
> with
>
Hmm, can't say I get the joke. I haven't really played with repr, though I
think I understand
On Wed, Jan 8, 2014 at 4:23 PM, eryksun wrote:
> You can create a worker thread with a larger stack using the threading
> module. On Windows the upper limit is 256 MiB, so give this a try:
>
quite excellent, mwahaha... another shovel to help me excavate out the
bottom of my hole... I'll play wi
On 01/08/2014 10:11 PM, Keith Winston wrote:
On Wed, Jan 8, 2014 at 3:42 PM, Emile van Sebille wrote:
Without seeing your code it's hard to be specific, but it's obvious you'll
need to rethink your approach. :)
Yes, it's clear I need to do the bulk of it without recusion, I haven't
reall
On Wed, Jan 8, 2014 at 3:25 PM, Keith Winston wrote:
> I've been playing with recursion, it's very satisfying.
>
> However, it appears that even if I sys.setrecursionlimit(10), it blows
> up at about 24,000 (appears to reset IDLE). I guess there must be a lot of
> overhead with recursion, if o
On Wed, Jan 8, 2014 at 3:42 PM, Emile van Sebille wrote:
>
> Without seeing your code it's hard to be specific, but it's obvious you'll
> need to rethink your approach. :)
Yes, it's clear I need to do the bulk of it without recusion, I haven't
really thought about how to do that. I may or may
On 1/8/2014 12:25 PM, Keith Winston wrote:
I've been playing with recursion, it's very satisfying.
However, it appears that even if I sys.setrecursionlimit(10), it
blows up at about 24,000 (appears to reset IDLE). I guess there must be
a lot of overhead with recursion, if only 24k times are
I've been playing with recursion, it's very satisfying.
However, it appears that even if I sys.setrecursionlimit(10), it blows
up at about 24,000 (appears to reset IDLE). I guess there must be a lot of
overhead with recursion, if only 24k times are killing my memory?
I'm playing with a challe
On Sat, Jun 8, 2013 at 4:52 PM, Jim Mooney wrote:
> Well, I thought
>
> if num > 10:
> return num
>
> Was a return statement. Num does become > 10. You mean I need more than
> one?
>
It is, and you actually have more than one. All functions return None,
unless you explicitly spec
On Tue, Aug 28, 2012 at 5:14 PM, Alan Gauld wrote:
> On 28/08/12 17:34, Steve Willoughby wrote:
>>> For some reason some beginners seem to find recursion a natural pattern.
>>
>>
>> There is a certain "hey, you can do that? That's cool!" factor when you
>> first discover recursion.
>
>
>
On 28/08/12 17:34, Steve Willoughby wrote:
For some reason some beginners seem to find recursion a natural pattern.
There is a certain "hey, you can do that? That's cool!" factor when you
first discover recursion.
My point was that it seems to be a natural idea for many beginners, they
dis
On 28-Aug-12 09:13, Alan Gauld wrote:
On 28/08/12 16:51, Dharmit Shah wrote:
@Dave Angel : Thank you for the loop idea. It didn't strike me at all.
For some reason some beginners seem to find recursion a natural pattern.
There is a certain "hey, you can do that? That's cool!" factor when yo
On 28-Aug-12 09:03, Mark Lawrence wrote:
On 28/08/2012 16:51, Dharmit Shah wrote:
@ Steve : Thank you. As suggested by Dave Angel, I am going to try the
loop. And even before implementing it, I can feel that it's going to
be more efficient than recursion.
May I ask why you appear to be conce
On 28/08/12 16:51, Dharmit Shah wrote:
@Dave Angel : Thank you for the loop idea. It didn't strike me at all.
For some reason some beginners seem to find recursion a natural pattern.
Many others, including quite experienced programmers find it a mind
bending concept.
But as a general rule, wh
On 28/08/2012 16:51, Dharmit Shah wrote:
@ Steve : Thank you. As suggested by Dave Angel, I am going to try the
loop. And even before implementing it, I can feel that it's going to
be more efficient than recursion.
May I ask why you appear to be concerned with efficiency for a hangman game?
Hello,
@Hugo Arts : Thank you! That was awesome to read. Thanks for the len()
suggestion.
@ Steve : Thank you. As suggested by Dave Angel, I am going to try the
loop. And even before implementing it, I can feel that it's going to
be more efficient than recursion.
@Dave Angel : Thank you for the
On 08/28/2012 07:23 AM, Dharmit Shah wrote:
> Hello,
>
> I am trying to do the following :
>
> 1) Ask user for the length of the word that he'd like to guess (for
> hangman game).
> 2) Pick a random word from /usr/share/dict/words (which I understand
> is not the best choice for hangman).
> 3) Call
On 28-Aug-12 04:23, Dharmit Shah wrote:
Hello,
I am trying to do the following :
1) Ask user for the length of the word that he'd like to guess (for
hangman game).
2) Pick a random word from /usr/share/dict/words (which I understand
is not the best choice for hangman).
3) Call a function that w
On Tue, Aug 28, 2012 at 1:23 PM, Dharmit Shah wrote:
> Hello,
>
> I am trying to do the following :
>
> 1) Ask user for the length of the word that he'd like to guess (for
> hangman game).
> 2) Pick a random word from /usr/share/dict/words (which I understand
> is not the best choice for hangman)
Hello,
I am trying to do the following :
1) Ask user for the length of the word that he'd like to guess (for
hangman game).
2) Pick a random word from /usr/share/dict/words (which I understand
is not the best choice for hangman).
3) Call a function that would pick a random word to proceed further
"Shawn Blazer" wrote
Hello! I'm a high school student, and I'm having some trouble
learning recursion in my class...
For example:
Trace the sequence of recursive calls that glee(2,1) spawns:
def glee ( idol , scrub ) :
if idol == 0 :
return scrub
elif idol < 0 :
return scrub + glee ( idol +
On 5/28/2010 3:09 PM Shawn Blazer said...
Hello! I'm a high school student, and I'm having some trouble learning
recursion in my class...
For example:
Trace the sequence of recursive calls that glee(2,1) spawns:
I imagine what you'd need to do is manually follow the code for glee
step-by-step
Hello! I'm a high school student, and I'm having some trouble learning
recursion in my class...
For example:
Trace the sequence of recursive calls that glee(2,1) spawns:
def glee ( idol , scrub ) :
if idol == 0 :
return scrub
elif idol < 0 :
return scrub + glee ( idol + 10 , idol % 3 )
else :
Anshu Raval wrote:
But my question would again be how do you know to put square brackets
around path in
if start == end:
return [path]
in find_all_paths. I am still puzzled by this.
find_all_paths() returns a *list* of paths, even when the result is a
single path. Without the brac
, 20 Apr 2008 03:21:03 +0200From: [EMAIL PROTECTED]: [EMAIL
PROTECTED]: Re: [Tutor] Recursion doubtCC: tutor@python.org
Hi,
you are tackling 3 "heavy" subjects in just 1 go!
graphs :a triving math society would approve your choice. But you might start
with the *slightly* less difficult chal
Hi,
you are tackling 3 "heavy" subjects in just 1 go!
graphs :a triving math society would approve your choice. But you might
start with the *slightly* less difficult challenge: trees.
I do not know your math/programming background, so the following link can
perhaps enlighten you: http://www.brpr
Hi,
At the url http://www.python.org/doc/essays/graphs.html there is some code by
Guido Van Rossum for computing paths through a graph - I have pasted it below
for reference -
Let's write a simple function to determine a path between two nodes. It takes a
graph and the start and end nodes as
Thank you!
I have a program myself that does a lot of recursion.
Regards,
Eike.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Eike Welk wrote:
> Hello Allan!
>
> On Monday 12 February 2007 22:17, Alan Gauld wrote:
>> The figure 999 is interesting. Python has a recursion limit of 1000
>> levels. Do you by any chance use recursion to call your function?
>
> Is the recursion limit hard coded, or can it be changed?
It is s
Andrei:
>Date: Sat, 29 Oct 2005 01:13:45 +0200
>From: Andrei <[EMAIL PROTECTED]>
>Subject: Re: [Tutor] Recursion and List Comprehensions
>To: tutor@python.org
>Message-ID: <[EMAIL PROTECTED]>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
<>
l, Barry
>Sent: Friday, October 28, 2005 5:49 PM
>To: 'Alan Gauld'; Carroll, Barry; tutor@python.org
>Subject: RE: [Tutor] Recursion and List Comprehensions
>
>Alan et al:
>
>After reading the topic you recommended I tried rewriting my permute
>function as follows:
&
ator (retList+= ...) causes this error:
>>>>>>>>>>
>>> permute.permute3('tests')
Traceback (most recent call last):
File "", line 1, in ?
File "permute.py", line 50, in permute3
retList+=[word[pos]+item for item in
perm
> Unfortunately, I don't understand how list comprehensions work and how to
> implement them. Can someone point me in the right direction, please.
Compare these two pieces of code
x=[1,2,3,4]
y=[]
for eachnum in x:
y.append(eachnum * 2)
versus
x=[1,2,3,4]
y = [each * 2 for each in x
Carroll, Barry wrote:
> Greetings:
> I'm trying to improve my programming and Python skills. To that end I
> have implemented a word jumble program as a recursive function: given a
> string of arbitrary length, return a list of all permutations of the
> string each character exactly once. In
Carroll, Barry wrote:
>> >>>permuteList=permute2(word[0:pos]+word[pos+1:len(word)])
>> >>># Now, tack the first char onto each word in the list
>> >>># and add it to the output
>> >>>for item in permuteList:
>> >>>retList.append(word[p
>def permute3 (word):
>retList=[]
>if len(word) == 1:
># There is only one possible permutation
>retList.append(word)
>else:
># Return a list of all permutations using all characters
>retlist = [a list comprehension that ca
Greetings:
I'm trying to improve my programming and Python
skills. To that end I have implemented a word jumble program as a
recursive function: given a string of arbitrary length, return a list of
all permutations of the string each character exactly once. In other
words:
pe
Hi all,
I'm playing about with some recursive functions where I am getting
near the recursion limit. This caused me to do a test, and I am
puzzled by the different results when run in the prompt, IDLE and
PythonWin.
My simple test code is:
>>> c = 0
>>> def recursion_test():
global c
62 matches
Mail list logo