[Tutor] Stop a long loop in python console or in wxpython?

2009-06-07 Thread xbmuncher
I have this script: import time def hello(): print "yay you got me to print" def longLoop(): x = 0 for n in range(10): time.sleep(5) x = x + n longLoop() It will run in the console for a long time. How can I send a command and cause it to stop and pursue hello(

Re: [Tutor] What is this kind of loop called

2009-06-07 Thread Emile van Sebille
On 6/7/2009 6:37 PM David said... In one of my questions to this list, Kent explained to me how to use a loop like this; #!/usr/bin/python from time import sleep def get(numbers): print 'Calling ', numbers sleep(1) print 'Connected ' sleep(1) def call_numbers(): for i in r

Re: [Tutor] [Fwd: Re: What is this kind of loop called]

2009-06-07 Thread Luke Paireepinart
def get(numbers): print 'Calling ', numbers sleep(1) print 'Connected ' sleep(1) def call_numbers(): for i in range(9549355543, 9549355560): numbers = i get(numbers) call_numbers() Is there a technical name for a loop like this? For loop? That is what I c

Re: [Tutor] creating a range above & below a given number

2009-06-07 Thread Kent Johnson
On Sun, Jun 7, 2009 at 3:34 PM, Emile van Sebille wrote: > To explain why we've tended to suggest using int and minval tests and avoid the range inclusion test, consider the following timeit > results: The performance penalty for 'in range(...)' is even greater when the value is not found, becaus

[Tutor] [Fwd: Re: What is this kind of loop called]

2009-06-07 Thread David
Forwarding to the list, forgot again :( -- Powered by Gentoo GNU/Linux http://linuxcrazy.com --- Begin Message --- bob gailer wrote: David wrote: In one of my questions to this list, Kent explained to me how to use a loop like this; #!/usr/bin/python from time import sleep def get(numbers):

Re: [Tutor] What is this kind of loop called

2009-06-07 Thread bob gailer
David wrote: In one of my questions to this list, Kent explained to me how to use a loop like this; #!/usr/bin/python from time import sleep def get(numbers): print 'Calling ', numbers sleep(1) print 'Connected ' sleep(1) def call_numbers(): for i in range(9549355543, 9549

[Tutor] What is this kind of loop called

2009-06-07 Thread David
In one of my questions to this list, Kent explained to me how to use a loop like this; #!/usr/bin/python from time import sleep def get(numbers): print 'Calling ', numbers sleep(1) print 'Connected ' sleep(1) def call_numbers(): for i in range(9549355543, 9549355560):

Re: [Tutor] gui menu

2009-06-07 Thread Essah Mitges
read bottom Date: Sun, 7 Jun 2009 21:48:55 + From: alan.ga...@btinternet.com Subject: Re: [Tutor] gui menu To: e_mit...@hotmail.com CC: tutor@python.org Forwarding to group. Please use Reply All when responding to the tutor group. Thanks for the extra information it is helpful. From: Essa

Re: [Tutor] gui menu

2009-06-07 Thread ALAN GAULD
Forwarding to group. Please use Reply All when responding to the tutor group. Thanks for the extra information it is helpful. From: Essah Mitges To: alan.ga...@btinternet.com Sent: Sunday, 7 June, 2009 10:32:27 PM Subject: RE: [Tutor] gui menu http://osdir.com/ml/python.pygame/2002-11/msg000

Re: [Tutor] gui menu

2009-06-07 Thread Alan Gauld
"Essah Mitges" wrote import sys, pygame pygame.init() background = pygame.image.load(""My png image 800x 532) backgroundRect = background.get_rect() size = (width, height) = background.get.size() screen = pygame.display.set_mode(size) screen.blit(background, backgroundRect) pygame.display.flip(

Re: [Tutor] creating a range above & below a given number

2009-06-07 Thread Emile van Sebille
On 6/7/2009 10:17 AM Gonzalo Garcia-Perate said... Emile, Kent thank you both for your reply, after sending my previous email I realised that it wasn't working as expected in all cases. this does work: def within_range_final(self, n, n2, threshold=5): return n in range(n2-threshold, n2+thr

Re: [Tutor] creating a range above & below a given number

2009-06-07 Thread Kent Johnson
On Sun, Jun 7, 2009 at 1:17 PM, Gonzalo Garcia-Perate wrote: > Emile, Kent thank you both for your reply, after sending my previous > email I realised that it wasn't working as expected in all cases. > > this does work: > > def within_range_final(self, n, n2, threshold=5): >     return n in range(n

[Tutor] gui menu

2009-06-07 Thread Essah Mitges
import sys, pygame pygame.init() background = pygame.image.load(""My png image 800x 532) backgroundRect = background.get_rect() size = (width, height) = background.get.size() screen = pygame.display.set_mode(size) screen.blit(background, backgroundRect) pygame.display.flip() I want to use pygame t

Re: [Tutor] vpython compatibility

2009-06-07 Thread Emile van Sebille
On 6/7/2009 10:48 AM roberto said... hello i have a short question: is vpython usable in conjunction with python 3.0 ? This is likely better answered by the vpython crowd -- I've not used or previously hear of vpython, but they're rather explicit on their download pages here http://vpython.o

[Tutor] vpython compatibility

2009-06-07 Thread roberto
hello i have a short question: is vpython usable in conjunction with python 3.0 ? i hope so, also vpython site for download doesn't issue any warning about this topic thank you -- roberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/

Re: [Tutor] creating a range above & below a given number

2009-06-07 Thread Gonzalo Garcia-Perate
Emile, Kent thank you both for your reply, after sending my previous email I realised that it wasn't working as expected in all cases. this does work: def within_range_final(self, n, n2, threshold=5): return n in range(n2-threshold, n2+threshold+1) What I have is an ultrasound sensor that g

Re: [Tutor] creating a range above & below a given number

2009-06-07 Thread Kent Johnson
On Sun, Jun 7, 2009 at 10:08 AM, Gonzalo Garcia-Perate wrote: >  the solution laid somewhere in between: > > def within_range(self, n, n2, threshold=5): >        if n in range(n2-threshold, n2+threshold+1) and n < > n2+threshold or n > n2 + threshold : return True >        return False This is a b

Re: [Tutor] creating a range above & below a given number

2009-06-07 Thread Emile van Sebille
On 6/7/2009 8:44 AM Emile van Sebille said... On 6/7/2009 7:08 AM Gonzalo Garcia-Perate said... the solution laid somewhere in between: def within_range(self, n, n2, threshold=5): if n in range(n2-threshold, n2+threshold+1) and n < n2+threshold or n > n2 + threshold : return True

Re: [Tutor] creating a range above & below a given number

2009-06-07 Thread Emile van Sebille
On 6/7/2009 7:08 AM Gonzalo Garcia-Perate said... the solution laid somewhere in between: def within_range(self, n, n2, threshold=5): if n in range(n2-threshold, n2+threshold+1) and n < n2+threshold or n > n2 + threshold : return True return False Be careful here -- you proba

Re: [Tutor] creating a range above & below a given number

2009-06-07 Thread Gonzalo Garcia-Perate
the solution laid somewhere in between: def within_range(self, n, n2, threshold=5): if n in range(n2-threshold, n2+threshold+1) and n < n2+threshold or n > n2 + threshold : return True return False This seems a bit more pythonic than my original function. Thank you both. 2009/6/

Re: [Tutor] converting xls to csv

2009-06-07 Thread Sander Sweers
On Sun, 2009-06-07 at 00:54 +0200, Sander Sweers wrote: > 2009/6/6 Nick Burgess : > > Is it posible to take > > the regex compile from user input? To make it take an argument, like > > > >> csvSearch.py 10.192.55 > > You can use raw_input() see [1] for the docs > user_input = raw_input('Please