Re: [Tutor] Loops

2015-04-05 Thread Steven D'Aprano
On Sun, Apr 05, 2015 at 01:11:06PM +0200, Marcus Lütolf wrote: > Why do I get this traceback with the infinite loop below but not with the > definitw loop (bottom of mail)? You forgot to show the definite loop, but the error in the infinite loop is explained by the error message. You should read

Re: [Tutor] Loops

2015-04-05 Thread Alan Gauld
On 05/04/15 12:11, Marcus Lütolf wrote: Why do I get this traceback with the infinite loop below but not with the definitw loop (bottom of mail)? I don;t see anyt loops at the bottom. But as for this one... count = 0 total = 0 while True: x = raw_input('Enter a number') raw_input read

Re: [Tutor] Loops

2015-04-05 Thread Mark Lawrence
On 05/04/2015 12:11, Marcus Lütolf wrote: Why do I get this traceback with the infinite loop below but not with the definitw loop (bottom of mail)? Thanks for help, Marcus. count = 0 total = 0 while True: x = raw_input('Enter a number') count = count + 1 total = total + x pr

Re: [Tutor] Loops and matrices'

2011-08-29 Thread Peter Otten
Reed DA (Danny) at Aera wrote: > I have a matrix which contains temperatures. The columns are time, spaced > 33 seconds apart, and the rows are depth intervals. What I'm trying to do > is create another matrix that contains the rate of change of temperature > for each depth. The array is called LS

Re: [Tutor] Loops and matrices'

2011-08-29 Thread Steven D'Aprano
Alan Gauld wrote: On 30/08/11 00:26, Emile van Sebille wrote: delta_temp(i,j) = (LS_JULY_11(i,j) - LS_JULY_11(i,j-1))/TIME_STEP delta_temp access and assignment likely wants to be expressed with brackets rather than parens. And for those not speaking the US variant of English that'll be squ

Re: [Tutor] Loops and matrices'

2011-08-29 Thread Alan Gauld
On 30/08/11 00:26, Emile van Sebille wrote: delta_temp(i,j) = (LS_JULY_11(i,j) - LS_JULY_11(i,j-1))/TIME_STEP delta_temp access and assignment likely wants to be expressed with brackets rather than parens. And for those not speaking the US variant of English that'll be square brackets as op

Re: [Tutor] Loops and matrices'

2011-08-29 Thread Emile van Sebille
On 8/29/2011 3:28 PM Reed DA (Danny) at Aera said... Hi all, I have a matrix which contains temperatures. The columns are time, spaced 33 seconds apart, and the rows are depth intervals. What I'm trying to do is create another matrix that contains the rate of change of temperature for each depth

Re: [Tutor] Loops and matrices'

2011-08-29 Thread Prasad, Ramit
Hi Danny, Most likely you want     delta_temp(i,j) = (LS_JULY_11(i,j) - LS_JULY_11(i,j-1))/TIME_STEP to become (changed the character from '()' to '[]':     delta_temp[i,j] = (LS_JULY_11(i,j) - LS_JULY_11(i,j-1))/TIME_STEP Basically it t

Re: [Tutor] loops

2009-12-08 Thread Lie Ryan
On 12/9/2009 3:18 AM, Rich Lovely wrote: 2009/12/8 spir: This, of course is a rather dirty, implementation (and probably version) specific hack, but I can /calculate/ the sequence, using just one line: print " ".join(str(i) for i in [x if x<2 else (locals()['_[1]'][-1]+locals()['_[1]'][-2]) f

Re: [Tutor] loops

2009-12-08 Thread Rich Lovely
2009/12/8 spir : > Lie Ryan dixit: > >> On 12/8/2009 9:39 PM, Dave Angel wrote: >> > Richard Hultgren wrote: >> >> a = 0 >> >> b = 1 >> >> count = 0 >> >> max_count = 20 >> >> while count < max_count: >> >> count = count + 1 >> >> # we need to keep track of a since we change it >> >> old_a = a # e

Re: [Tutor] loops

2009-12-08 Thread spir
Lie Ryan dixit: > On 12/8/2009 9:39 PM, Dave Angel wrote: > > Richard Hultgren wrote: > >> a = 0 > >> b = 1 > >> count = 0 > >> max_count = 20 > >> while count < max_count: > >> count = count + 1 > >> # we need to keep track of a since we change it > >> old_a = a # especially here > >> old_b = b

Re: [Tutor] loops

2009-12-08 Thread Lie Ryan
On 12/8/2009 9:39 PM, Dave Angel wrote: Richard Hultgren wrote: a = 0 b = 1 count = 0 max_count = 20 while count < max_count: count = count + 1 # we need to keep track of a since we change it old_a = a # especially here old_b = b a = old_b b = old_a + old_b # Notice that the , at the end of a pr

Re: [Tutor] loops

2009-12-08 Thread Dave Angel
Richard Hultgren wrote: a = 0 b = 1 count = 0 max_count = 20 while count < max_count: count = count + 1 # we need to keep track of a since we change it old_a = a# especially here old_b = b a = old_b b = old_a + old_b # Notice that the , at the end of a

Re: [Tutor] loops

2009-12-07 Thread Kent Johnson
Is there a question here? Please skip the giant type size. Kent On Mon, Dec 7, 2009 at 2:53 PM, Richard Hultgren wrote: > a = 0 > b = 1 > count = 0 > max_count = 20 > while count < max_count: >     count = count + 1 >     # we need to keep track of a since we change it >     old_a = a   

Re: [Tutor] loops

2009-04-29 Thread Lie Ryan
Norman Khine wrote: hello, i have the following code: Uhh... 5 levels deep of nesting, and from the hint that you used self.blah earlier this is inside a class which adds a minimum of two extra levels, in total of 7 levels nesting... We're in deep trouble. is there a way to optimise the lo

Re: [Tutor] loops

2009-04-29 Thread Kent Johnson
On Wed, Apr 29, 2009 at 3:05 AM, Norman Khine wrote: > hello, > i have the following code: > > if unique_id is not None: >    training = self.get_site_root() >    from training import Training >    # link back to news item >    root = context.root >    formats = ['itinerary', 'news'] >    for docu

Re: [Tutor] loops

2009-04-29 Thread spir
Le Wed, 29 Apr 2009 09:42:44 +0200, "A.T.Hofkamp" s'exprima ainsi: > Norman Khine wrote: > > hello, > > i have the following code: > > > > if unique_id is not None: > > training = self.get_site_root() > > from training import Training > > # link back to news item > > root = conte

Re: [Tutor] loops

2009-04-29 Thread A.T.Hofkamp
Norman Khine wrote: hello, i have the following code: if unique_id is not None: training = self.get_site_root() from training import Training # link back to news item root = context.root formats = ['itinerary', 'news'] for document in formats: results = root.searc

Re: [Tutor] Loops

2009-02-14 Thread pa yo
Thanks Alan. after a few hours scratching my head I finally fixed it by removing all the indents and remaking them in the correct position. Payo On Sat, Feb 14, 2009 at 1:52 AM, Alan Gauld wrote: > "pa yo" wrote > >> The way I have come up with to solve this problem is to put the >> following

Re: [Tutor] Loops

2009-02-13 Thread Alan Gauld
"pa yo" wrote The way I have come up with to solve this problem is to put the following loop in: rawfeed = feedparser(http//twitter.com/foobar) feedstring = rawfeed.split('=',1)#this splits the feed at the first "=" headline = feedstring[0]#this is the text i

Re: [Tutor] loops, variables and strings

2008-07-05 Thread bob gailer
James wrote: All, I'm trying to do something pretty simple, but I can't seem to get Python to behave nicely. :) I'd like to automate a script that sends out three or four lists in an e-mail. I have a function dedicated to sending e-mail that will take a string variable, slap it in a message, an

Re: [Tutor] loops, variables and strings

2008-07-05 Thread Monika Jisswel
maybe StringIO ? MsgBody = StringIO.StringIO() print >> MsgBody, "Hello. Below is an automated e-mail with important statistics." print >> MsgBody, ""#empty line print >> MsgBody, ""#empty line print >> MsgBody, "The following user accounts expired today:" print >> MsgBody, " - " %

Re: [Tutor] Loops and modules

2007-12-06 Thread bhaaluu
On Dec 6, 2007 8:38 AM, richard west <[EMAIL PROTECTED]> wrote: > heres a partial solution. theres no error checking on the Raw Input and you > have to type in you last number and press return, before the loop will > break, but its a start! And modifying your modifications makes it work even a l

Re: [Tutor] Loops and modules

2007-12-06 Thread richard west
heres a partial solution. theres no error checking on the Raw Input and you have to type in you last number and press return, before the loop will break, but its a start! #!/usr/bin/python # Filename : math_test.py import time import threading class Timer(threading.Thread): def __init__(self

Re: [Tutor] loops to assign variables

2006-07-26 Thread Alan Gauld
I'm reading the gmane news archive to see what I missed while on vacation and noticed this. Sorry the response is so late... "John CORRY" <[EMAIL PROTECTED]> wrote > For example, I have 30 textentry boxes numbered from entry20 to > entry50. > I have used the following code to assign the entrybox

Re: [Tutor] loops to assign variables

2006-07-23 Thread Alan Gauld
I've been on vacation so missed the start of this, apologies if i'm missing a point somewhere but... > Ah. I see. A copy, eh? Or, at least a new dictionary separate > from the "real" namespace. OK. I don't know why locals() returns > a copy as opposed to the original, What else can it do? W

Re: [Tutor] loops to assign variables

2006-07-22 Thread Dave Kuhlman
On Sat, Jul 22, 2006 at 01:41:17PM -0400, Kent Johnson wrote: > Dave Kuhlman wrote: [snip] > > And, also, that's why the following statements all have exactly > > the same effect: > > > > total = 5 > > locals()['total'] = 5 > > exec('total = 5') > > You're not in the mood to believe

Re: [Tutor] loops to assign variables

2006-07-22 Thread Kent Johnson
Dave Kuhlman wrote: > On Sat, Jul 22, 2006 at 11:37:38AM -0400, Python wrote: > >> >> Well the reference documentation says: >> >> locals( >> ) >> Update and return a dictionary representing the current local >> symbol table. Warning: The contents of this dictionary should >>

Re: [Tutor] loops to assign variables

2006-07-22 Thread Dave Kuhlman
On Sat, Jul 22, 2006 at 11:37:38AM -0400, Python wrote: > On Sat, 2006-07-22 at 17:18 +0200, Karl Pflästerer wrote: > > On 22 Jul 2006, [EMAIL PROTECTED] wrote: > > > > > > > > On Sat, 2006-07-22 at 14:11 +0100, John CORRY wrote: > > >> Hi, > > >> > > >> I am refactoring my code. I am trying to

Re: [Tutor] loops to assign variables

2006-07-22 Thread Python
On Sat, 2006-07-22 at 17:18 +0200, Karl Pflästerer wrote: > On 22 Jul 2006, [EMAIL PROTECTED] wrote: > > > > > On Sat, 2006-07-22 at 14:11 +0100, John CORRY wrote: > >> Hi, > >> > >> I am refactoring my code. I am trying to reduce the amount of lines > >> by using more loops. I tend to use cop

Re: [Tutor] loops to assign variables

2006-07-22 Thread Karl Pflästerer
On 22 Jul 2006, [EMAIL PROTECTED] wrote: > > On Sat, 2006-07-22 at 14:11 +0100, John CORRY wrote: >> Hi, >> >> I am refactoring my code. I am trying to reduce the amount of lines >> by using more loops. I tend to use copy and paste a lot instead of >> writing a loop to do the work. >> >> For

Re: [Tutor] loops to assign variables

2006-07-22 Thread Python
On Sat, 2006-07-22 at 14:11 +0100, John CORRY wrote: > Hi, > > I am refactoring my code. I am trying to reduce the amount of lines > by using more loops. I tend to use copy and paste a lot instead of > writing a loop to do the work. > > For example, I have 30 textentry boxes numbered from ent