[Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Richard D. Moores
Traceback (most recent call last): File "c:\P26Working\test_urllib2_21a.py", line 148, in unchanged_count, higher_count, lower_count, secs = sleep_seconds_control(unchanged_count, higher_count, lower_count, secs) TypeError: 'int' object is not iterable I'm working on a script that keeps tra

[Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-23 Thread col speed
> > Message: 7 > Date: Fri, 22 Oct 2010 21:48:29 -0700 > From: "Richard D. Moores" > To: "Steven D'Aprano" > Cc: tutor@python.org > Subject: Re: [Tutor] What does "TypeError: 'int' object is not >iterable" mean? &

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Tim Golden
On 21/10/2010 13:42, Richard D. Moores wrote: Traceback (most recent call last): File "c:\P26Working\test_urllib2_21a.py", line 148, in unchanged_count, higher_count, lower_count, secs = sleep_seconds_control(unchanged_count, higher_count, lower_count, secs) TypeError: 'int' object is not

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Emmanuel Ruellan
On Thu, Oct 21, 2010 at 2:42 PM, Richard D. Moores wrote: Traceback (most recent call last): File "c:\P26Working\test_urllib2_ > > 21a.py", line 148, in >unchanged_count, higher_count, lower_count, secs = > sleep_seconds_control(unchanged_count, higher_count, lower_count, > secs) > TypeErro

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Eloy Zuniga Jr.
One of your variables (e.g. unchanged_count, higher_count, lower_count, secs) is an integer and your method expects a sequence (iterable) value. Examples of iterable values: 1. str 2. unicode 3. list 4. tuple 5. xrange and range On Thu, Oct 21, 2010 at 7:42 AM, Richard D. Moores

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Eloy Zuniga Jr.
Forget what I said. Tim's right. Return an iterable from within your method not an integer. On Thu, Oct 21, 2010 at 7:52 AM, Tim Golden wrote: > On 21/10/2010 13:42, Richard D. Moores wrote: > >> Traceback (most recent call last): >> File "c:\P26Working\test_urllib2_21a.py", line 148, in >>

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Christian Witts
On 21/10/2010 14:42, Richard D. Moores wrote: Traceback (most recent call last): File "c:\P26Working\test_urllib2_21a.py", line 148, in unchanged_count, higher_count, lower_count, secs = sleep_seconds_control(unchanged_count, higher_count, lower_count, secs) TypeError: 'int' object is not

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Alan Gauld
"Richard D. Moores" wrote unchanged_count, higher_count, lower_count, secs = sleep_seconds_control(unchanged_count, higher_count, lower_count, secs) TypeError: 'int' object is not iterable I'm at a loss as to what the error means. a.. def sleep_seconds_control(unchanged_count, higher_cou

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Richard D. Moores
Wow! What great help! Thanks! In case anyone's interested, the script now works the way I wanted: . It should work for anyone with 2.6 or 2.7 I'd appreciate constructive criticism. Dick ___ Tutor maillist - Tuto

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Sander Sweers
On 21 October 2010 18:09, Richard D. Moores wrote: > In case anyone's interested, the script now works the way I wanted: > . It should work for anyone > with 2.6 or 2.7 > > I'd appreciate constructive criticism. Instead of all the zeros2float craziness use s

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Richard D. Moores
On Thu, Oct 21, 2010 at 14:21, Sander Sweers wrote: > On 21 October 2010 18:09, Richard D. Moores wrote: >> I'd appreciate constructive criticism. > > Instead of all the zeros2float craziness use string formatting. It > will take care of rounding and the number of decimal places. > import d

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-22 Thread Richard D. Moores
On Thu, Oct 21, 2010 at 15:44, Richard D. Moores wrote: >> If you want to control the number of decimal places in the string >> formatting do something like: >> > i = 3 > print ("NEW LOW: %%.%sf at %%s" % i) % (lowz, timestamp) >> NEW LOW: 81.750 at 22:55:13 > i = 6 > print ("NEW L

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-22 Thread David Hutto
On Fri, Oct 22, 2010 at 9:42 AM, Richard D. Moores wrote: > On Thu, Oct 21, 2010 at 15:44, Richard D. Moores wrote: >>> If you want to control the number of decimal places in the string >>> formatting do something like: >>> >> i = 3 >> print ("NEW LOW: %%.%sf at %%s" % i) % (lowz, timesta

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-22 Thread Richard D. Moores
On Fri, Oct 22, 2010 at 06:47, David Hutto wrote: >> which works fine, but a question remains: n is an integer. Why the 's' >> in '%sf'? > > Right here: > http://docs.python.org/release/2.5.2/lib/typesseq-strings.html Sorry, but I don't see the answer to my question there. Dick _

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-22 Thread David Hutto
On Fri, Oct 22, 2010 at 9:55 AM, Richard D. Moores wrote: > On Fri, Oct 22, 2010 at 06:47, David Hutto wrote: >>> which works fine, but a question remains: n is an integer. Why the 's' >>> in '%sf'? >> >> Right here: >> http://docs.python.org/release/2.5.2/lib/typesseq-strings.html > > Sorry, but

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-22 Thread David Hutto
If I understand what i just said correctly, it just means it tells the string what type to convert from when placing it into the final result. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/ma

Re: [Tutor] What does "TypeError: 'int' object is not iterable"mean?

2010-10-22 Thread Alan Gauld
"Richard D. Moores" wrote return ("%%.%sf" % n) % floatt which works fine, but a question remains: n is an integer. Why the 's' in '%sf'? Its arbitrary. You could use %d just as easily. %s will put the numner into the string, so will %d. %d is probably a bit more picky about what it in

Re: [Tutor] What does "TypeError: 'int' object is not iterable"mean?

2010-10-22 Thread Richard D. Moores
On Fri, Oct 22, 2010 at 11:27, Alan Gauld wrote: > > "Richard D. Moores" wrote > >>   return ("%%.%sf" % n) % floatt >> >> which works fine, but a question remains: n is an integer. Why the 's' >> in '%sf'? > > Its arbitrary. You could use %d just as easily. > %s will put the numner into the stri

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-22 Thread Steven D'Aprano
On Sat, 23 Oct 2010 12:42:50 am Richard D. Moores wrote: > So I wrote a function: > > def float2n_decimals(floatt, n): > """ > Given a float (floatt), return floatt to n decimal places. > > E.g., with n = 2, 81.34567 -> 81.35 > """ > return ("%%.%sf" % n) % floatt > > which wor

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-22 Thread Richard D. Moores
It's great to have you chime in, Steven. I do wish you would stop pulling your punches, however. ;) On Fri, Oct 22, 2010 at 17:23, Steven D'Aprano wrote: > On Sat, 23 Oct 2010 12:42:50 am Richard D. Moores wrote: > >> So I wrote a function: >> >> def float2n_decimals(floatt, n): >>     """ >>    

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-23 Thread Dave Angel
On 2:59 PM, Richard D. Moores wrote: It's great to have you chime in, Steven. I do wish you would stop pulling your punches, however. ;) On Fri, Oct 22, 2010 at 17:23, Steven D'Aprano wrote: On Sat, 23 Oct 2010 12:42:50 am Richard D. Moores wrote: So I wrote a function: def float2n_decimals

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-23 Thread Steven D'Aprano
On Sat, 23 Oct 2010 09:43:07 pm Dave Angel wrote: > On 2:59 PM, Richard D. Moores wrote: [...] > >> float2n_decimals(x, 3) > >> > >> is better written in place as: > >> > >> "%.*f" % (3, x) > >> > >> There's no need for a function for something so simple. > > > > Yes, but I needed one for ("%%.%sf"

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-23 Thread Richard D. Moores
On Sat, Oct 23, 2010 at 03:43, Dave Angel wrote: > On 2:59 PM, Richard D. Moores wrote: >> >> It's great to have you chime in, Steven. I do wish you would stop >> pulling your punches, however. ;) >> >> On Fri, Oct 22, 2010 at 17:23, Steven D'Aprano >>  wrote: >>> float2n_decimals(x, 3) >>> >>> i

Re: [Tutor] What does "TypeError: 'int' object is not iterable"mean?

2010-10-23 Thread Alan Gauld
"Steven D'Aprano" wrote It would have to be a *very* old version. The use of * as the width parameter in format strings goes back to the Dark Ages of Python 1.5: ... I believe this is a virtual copy of string formatting from C, in which case it probably goes back to the 80s or even the 70s

Re: [Tutor] What does "TypeError: 'int' object is not iterable"mean?

2010-10-23 Thread Adam Bark
On 23/10/10 13:38, Alan Gauld wrote: "Steven D'Aprano" wrote It would have to be a *very* old version. The use of * as the width parameter in format strings goes back to the Dark Ages of Python 1.5: ... I believe this is a virtual copy of string formatting from C, in which case it probably go

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-24 Thread Richard D. Moores
On Sat, Oct 23, 2010 at 02:28, col speed wrote: > > >> >> >> Message: 7 >> Date: Fri, 22 Oct 2010 21:48:29 -0700 >> From: "Richard D. Moores" >> To: "Steven D'Aprano" >> Cc: tutor@python.org >> Subject: Re: [

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-24 Thread Lie Ryan
On 10/23/10 01:19, David Hutto wrote: > If I understand what i just said correctly, it just means it tells the > string what type to convert from when placing it into the final > result. basically, when doing this %-interpolation, python does this: ("NEW LOW: %%.%sf at %%s" % i) % (lowz, time