Hello There, Guest! Login or Register (why?)

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I forgot how to create a Infinite Counting Loop
11-12-2009, 01:34 AM (This post was last modified: 11-12-2009 01:39 AM by Anman.)
Post: #1
I forgot how to create a Infinite Counting Loop
And cant seem to find info on such a thing on it in the manual

python Code:
  1. c=0
  2. def a():
  3. global c
  4. c=c+1
  5. print ( c )
  6. a()

i get the error
" File "<stdin>", line 5, in a
. . .
File "<stdin>", line 5, in a
RuntimeError: maximum recursion depth exceeded"
how can i create a infinite loop whereas instead of giving a error saying that its an infinite loop it gives me the number? and continues to add and add
and no it doesn't change anything if you have it stop after it reaches x

http://www.youtube.com/watch?v=iyXYot6wHuE
Visit this user's website Find all posts by this user
Quote this message in a reply
11-12-2009, 01:38 AM (This post was last modified: 11-12-2009 01:39 AM by Anman.)
Post: #2
RE: I forgot how to create a Infinite Counting Loop
Should be print( c ) not print ( c )

HTML-Tricks
Find all posts by this user
Quote this message in a reply
11-12-2009, 01:44 AM (This post was last modified: 11-12-2009 01:52 AM by GenDeath.)
Post: #3
RE: I forgot how to create a Infinite Counting Loop
hahah wow i wish i wouldve noticed that Frown

Okay new issue
python Code:
  1. import sys
  2. sys.setrecursionlimit(100000000000)
  3. c=0
  4. def a():
  5. global c
  6. if c < 10000000000:
  7. c=c+1
  8. print©
  9. a()
  10. else:
  11. print("Done")


it now gives RuntimeError: maximum recursion depth exceeded in cmp

and these
File "<stdin>", line 6, in a
File "<stdin>", line 6, in a
File "<stdin>", line 6, in a
File "<stdin>", line 6, in a
File "<stdin>", line 6, in a
File "<stdin>", line 3, in a

http://www.youtube.com/watch?v=iyXYot6wHuE
Visit this user's website Find all posts by this user
Quote this message in a reply
11-12-2009, 04:36 AM
Post: #4
RE: I forgot how to create a Infinite Counting Loop
Why do you need an infinite loop?

Projects:
SteamAPI
Visit this user's website Find all posts by this user
Quote this message in a reply
11-12-2009, 06:14 AM (This post was last modified: 11-12-2009 06:19 AM by Anman.)
Post: #5
RE: I forgot how to create a Infinite Counting Loop
100000000000 needs to be set to 10000

For more info see http://docs.python.org/library/sys.html

And you are aware you could just use a loop to do this right?

HTML-Tricks
Find all posts by this user
Quote this message in a reply
11-13-2009, 06:06 AM
Post: #6
RE: I forgot how to create a Infinite Counting Loop
(11-12-2009 01:38 AM)Anman Wrote:  Should be print( c ) not print ( c )
Does not change anything, at least not in the python version I'm using.

Also, changing the recursion limit and stuff is just quite unnecessary if you haven't got a specific reason not to use a normal loop.
Find all posts by this user
Quote this message in a reply
11-13-2009, 01:13 PM
Post: #7
RE: I forgot how to create a Infinite Counting Loop
(11-12-2009 01:34 AM)GenDeath Wrote:  And cant seem to find info on such a thing on it in the manual

python Code:
  1. c=0
  2. def a():
  3. global c
  4. c=c+1
  5. print ( c )
  6. a()

i get the error
" File "<stdin>", line 5, in a
. . .
File "<stdin>", line 5, in a
RuntimeError: maximum recursion depth exceeded"
how can i create a infinite loop whereas instead of giving a error saying that its an infinite loop it gives me the number? and continues to add and add
and no it doesn't change anything if you have it stop after it reaches x

If your program is that simple can't you just use a for loop? Or do you need this running in the background while your running another piece of code.

[Image: zepplin.png]
Find all posts by this user
Quote this message in a reply
11-18-2009, 11:17 AM (This post was last modified: 11-18-2009 11:18 AM by GenDeath.)
Post: #8
RE: I forgot how to create a Infinite Counting Loop
well actually I used to do infinite loops just for stress testing my comp seeing how many infinite counting loops I could create and play video games as well as play music simultaneously.
Its not so much I need it its just making me mad that i sued to be able to do it and now I can't.

http://www.youtube.com/watch?v=iyXYot6wHuE
Visit this user's website Find all posts by this user
Quote this message in a reply
11-20-2009, 04:14 AM
Post: #9
RE: I forgot how to create a Infinite Counting Loop
Something like:
python Code:
  1. while 1:
  2. pass

or if you want it to count(so it actually does something)

python Code:
  1. x = 1
  2. while x != 0:
  3. x += 1
Find all posts by this user
Quote this message in a reply
11-21-2009, 07:04 AM (This post was last modified: 11-21-2009 09:52 AM by Anman.)
Post: #10
RE: I forgot how to create a Infinite Counting Loop
(11-20-2009 04:14 AM)Siretu Wrote:  Something like:
python Code:
  1. while 1:
  2. pass

or if you want it to count(so it actually does something)

[/code]

Couldn't that overflow though? It should be

python Code:
  1. x = 1
  2. while 0 = 1:
  3. x += 1

[Image: zepplin.png]
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


Contact UsLastCode.netReturn to TopReturn to ContentLite ModeRSS