Re: Enumerate - int object not subscriptable

2019-08-21 Thread Peter Otten
Sayth Renshaw wrote: > def output_data(s): > serie = fibo(input_length) > x = [] > y = [] > > for num1, num2 in pairwise(serie): > y.append( num2 / num1) It looks like y contains unique values. In that case replace > for item in y: > x.append(y.index(item

Re: Enumerate - int object not subscriptable

2019-08-20 Thread Sayth Renshaw
On Wednesday, 21 August 2019 03:16:01 UTC+10, Ian wrote: > Or use the "pairwise" recipe from the itertools docs: > > from itertools import tee > > def pairwise(iterable): > "s -> (s0,s1), (s1,s2), (s2, s3), ..." > a, b = tee(iterable) > next(b, None) > return zip(a, b) > > for n

Re: Enumerate - int object not subscriptable

2019-08-20 Thread Ian Kelly
Or use the "pairwise" recipe from the itertools docs: from itertools import tee def pairwise(iterable): "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) next(b, None) return zip(a, b) for num1, num2 in pairwise(a): print(num1, num2) On Tue, Aug 20, 2019 at 7:42 AM

Re: Enumerate - int object not subscriptable

2019-08-20 Thread Cousin Stanley
Sayth Renshaw wrote: > I want to do basic math with a list. > > a = [1, 2, 3, 4, 5, 6, 7, 8] > > for idx, num in enumerate(a): > print(idx, num) > > This works, but say I want to print the item value > at the next index as well as the current. > > for idx, num in enumerate(a): > > print(n

Re: Enumerate - int object not subscriptable

2019-08-20 Thread BlindAnagram
On 20/08/2019 13:00, Sayth Renshaw wrote: > Hi > > I want to do basic math with a list. > > > for idx, num in enumerate(a): > print(idx, num) > > This works, but say I want to print the item value at the next index as well > as the current. > > for idx, num in enumerate(a): > print(

Re: Enumerate - int object not subscriptable

2019-08-20 Thread Frank Millman
): print(num[idx + 1], num) I am expecting 2, 1. But am receiving TypeError: 'int' object is not subscriptable Why? I think you want a[idx+1], not num[idx+1]. Bear in mind that you will get IndexError for the last item in the list. Frank Millman -- https://mail.python.org/mailma

Enumerate - int object not subscriptable

2019-08-20 Thread Sayth Renshaw
, 1. But am receiving TypeError: 'int' object is not subscriptable Why? Cheers Sayth -- https://mail.python.org/mailman/listinfo/python-list

Re: TypeError: 'int' object is not callable

2013-08-27 Thread Terry Reedy
post, it is not always so obvious. Post the whole trackeback with errors. It is printed for a reason ;-) TypeError: 'int' object is not callable why is this error and how can i solve this problem? -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: 'int' object is not callable

2013-08-26 Thread Krishnan Shankar
returns non zero if defined. >>> import time >>> a = time.daylight() Traceback (most recent call last): File "", line 1, in TypeError: 'int' object is not callable >>> a = time.daylight >>> a 0 >>> type(time.daylight) Regards, Kr

TypeError: 'int' object is not callable

2013-08-26 Thread autobotprime . 17
dear friends when i try to execute following lines import time a = time.daylight() print(a) result is TypeError: 'int' object is not callable why is this error and how can i solve this problem? -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: Can't convert 'int' object to str implicitly

2013-04-26 Thread Dave Angel
On 04/26/2013 02:02 PM, Chris Angelico wrote: Here's a massive simplification of the OP's program: 1. Build a list of device IDs 2. Edit the file "firstdev.ahk" and replace all instances of "device" with the device ID 3. Execute the now-edited firstdev.ahk using os.system() 4. Reverse th

Re: TypeError: Can't convert 'int' object to str implicitly

2013-04-26 Thread Chris Angelico
On Sat, Apr 27, 2013 at 3:52 AM, Dave Angel wrote: > On 04/26/2013 01:28 PM, Chris Angelico wrote: >> >> On Sat, Apr 27, 2013 at 3:23 AM, Dave Angel wrote: >>> >>> On 04/26/2013 11:05 AM, Chris Angelico wrote: I've checked out what fileinput.input() is doing here (ought to have don

Re: TypeError: Can't convert 'int' object to str implicitly

2013-04-26 Thread Dave Angel
On 04/26/2013 01:28 PM, Chris Angelico wrote: On Sat, Apr 27, 2013 at 3:23 AM, Dave Angel wrote: On 04/26/2013 11:05 AM, Chris Angelico wrote: I've checked out what fileinput.input() is doing here (ought to have done that earlier, sorry!) and I now understand this block of code more. You're re

Re: TypeError: Can't convert 'int' object to str implicitly

2013-04-26 Thread Chris Angelico
On Sat, Apr 27, 2013 at 3:23 AM, Dave Angel wrote: > On 04/26/2013 11:05 AM, Chris Angelico wrote: >> I've checked out what fileinput.input() is doing here (ought to have >> done that earlier, sorry!) and I now understand this block of code >> more. You're replacing that word _in the file, on disk

Re: TypeError: Can't convert 'int' object to str implicitly

2013-04-26 Thread Dave Angel
On 04/26/2013 11:05 AM, Chris Angelico wrote: On Sat, Apr 27, 2013 at 12:26 AM, wrote: ##This next step will seek out the word Device within firstdev.ahk, and replace with devlist[0] for line in fileinput.input(["firstdev.ahk"], inplace=True): line = line.replace("device", devlist[0])

Re: TypeError: Can't convert 'int' object to str implicitly

2013-04-26 Thread Chris Angelico
On Sat, Apr 27, 2013 at 1:22 AM, wrote: >> I've checked out what fileinput.input() is doing here (ought to have >> >> done that earlier, sorry!) and I now understand this block of code >> >> more. You're replacing that word _in the file, on disk_, and then >> >> making the inverse replacement. Th

Re: TypeError: Can't convert 'int' object to str implicitly

2013-04-26 Thread tunacubes
On Friday, April 26, 2013 11:05:29 AM UTC-4, Chris Angelico wrote: > On Sat, Apr 27, 2013 at 12:26 AM, wrote: > > > ##This next step will seek out the word Device within firstdev.ahk, and > > replace with devlist[0] > > > for line in fileinput.input(["firstdev.ahk"], inplace=True): > > >

Re: TypeError: Can't convert 'int' object to str implicitly

2013-04-26 Thread tunacubes
t; > > Macro, change the device number back to the word "Device" for future use, > > > and then delete the first number from the list. It will repeat as long as > > > there are numbers in the list. > > > > > > The error I receive is "

Re: TypeError: Can't convert 'int' object to str implicitly

2013-04-26 Thread Chris Angelico
On Sat, Apr 27, 2013 at 12:26 AM, wrote: > ##This next step will seek out the word Device within firstdev.ahk, and > replace with devlist[0] > for line in fileinput.input(["firstdev.ahk"], inplace=True): > line = line.replace("device", devlist[0]) > sys.stdout.write(line) > ##next step r

Re: TypeError: Can't convert 'int' object to str implicitly

2013-04-26 Thread Chris Angelico
On Sat, Apr 27, 2013 at 12:26 AM, wrote: > Hey, > The error I receive is "TypeError: Can't convert 'int' object to str > implicitly" when it tries to put the device into the macro script. It worked > fine when I just had it input one device into the script

Re: TypeError: Can't convert 'int' object to str implicitly

2013-04-26 Thread Peter Otten
ot;device" with the first device in the list. It then should execute the > Macro, change the device number back to the word "Device" for future use, > and then delete the first number from the list. It will repeat as long as > there are numbers in the list. > > The err

TypeError: Can't convert 'int' object to str implicitly

2013-04-26 Thread tunacubes
change the device number back to the word "Device" for future use, and then delete the first number from the list. It will repeat as long as there are numbers in the list. The error I receive is "TypeError: Can't convert 'int' object to str implicitly" when it trie

Re: int object

2012-04-28 Thread Emile van Sebille
On 4/27/2012 11:42 PM Debashish Saha said... 44 sph_yn_P=(l*sph_yn(l,K*R)/(K*R))-sph_yn(l,K*R) Here you're clearly multiplying by R... ---> 45 Beta_l=l-(K_P*R(sph_jv(l+1,K_P*R))/(sph_jv(l,K_P*R))) ... and here you've got R(...) which is attempting to call R() which isn't def

int object

2012-04-27 Thread Debashish Saha
43 sph_jv_P=(l*sph_jv(l,K*R)/(K*R))-sph_jv(l,K*R) 44 sph_yn_P=(l*sph_yn(l,K*R)/(K*R))-sph_yn(l,K*R) ---> 45 Beta_l=l-(K_P*R(sph_jv(l+1,K_P*R))/(sph_jv(l,K_P*R))) 46 return arctan((K*R*sph_jv_P-Beta_l*sph_jv(l,K*R))/(K*R*sph_yn_P-Beta_l*sph_yn(l,K*R))) 47 Typ

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-10 Thread J. Cliff Dyer
On Thu, 2009-07-09 at 13:53 +, Friðrik Már Jónsson wrote: > Look at: > >len = len(text) > > You're overriding `len` (a built-in method), with an integer > (`len(text)`). You then call: > >for i in range(len(fields)): > > But `len` is no longer a callable, but merely an integer. >

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-10 Thread Nick
On Jul 9, 8:22 pm, Paul Rubin wrote: > Nick writes: > > text = file.readlines() > > len = len(text) > > fields = text[1].split() > > Is that intended to split the first line of the file? Remember > that arrays in python begin at index 0. no the '1st line' is garble

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-10 Thread Lie Ryan
Simon Forman wrote: > On Thu, Jul 9, 2009 at 9:42 AM, Nick wrote: > >>fields = line.split() >>for i in range(len(fields)): >>fields[i] = float(fields[i]) > > > instead of the above code you could say: > > fields = [float(n) for n in in line.split()] > > Have fun getting back in

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-10 Thread Lie Ryan
Friðrik Már Jónsson wrote: > Hi Rhodri, > >> It's only really a pitfall if you try to use the built-in after you've >> redefined it. That's the thing to keep an eye open for. > > You're right, but in cases where you're editing a codebase which you > didn't author entirely by yourself you may not

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Paul Rubin
Nick writes: > text = file.readlines() > len = len(text) > fields = text[1].split() Is that intended to split the first line of the file? Remember that arrays in python begin at index 0. -- http://mail.python.org/mailman/listinfo/python-list

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Simon Forman
On Thu, Jul 9, 2009 at 9:42 AM, Nick wrote: >    fields = line.split() >    for i in range(len(fields)): >        fields[i] = float(fields[i]) instead of the above code you could say: fields = [float(n) for n in in line.split()] Have fun getting back into python! :] (A lot has changed in the

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Friðrik Már Jónsson
Hi Rhodri, It's only really a pitfall if you try to use the built-in after you've redefined it. That's the thing to keep an eye open for. You're right, but in cases where you're editing a codebase which you didn't author entirely by yourself you may not be aware of that. That said, if the

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Rhodri James
On Thu, 09 Jul 2009 17:06:45 +0100, Tom Kermode wrote: Hi, Do you know a good way to avoid running into this problem? It makes sense to suggest not calling variables the same names as built-in functions, but that's hard for a new python programmer who doesn't already know what all the buil

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Friðrik Már Jónsson
Tom Kermode wrote: Do you know a good way to avoid running into this problem? It makes sense to suggest not calling variables the same names as built-in functions, but that's hard for a new python programmer who doesn't already know what all the built-in functions are. One way is using a code

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Richard Brodie
"Tom Kermode" wrote in message news:mailman.2903.1247155607.8015.python-l...@python.org... > Do you know a good way to avoid running into this problem? It > makes sense to suggest not calling variables the same names as > built-in functions, but that's hard for a new python programmer who > do

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Tom Kermode
lines() >> len = len(text) > > You have redefined two built-in functions "file" and "len" in the first three > lines. > This is usually considered poor practice. Stick to meaningless variable names, > it's safer (only joking). > > TypeError: &

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Nick
no problem, i understand, i haven't coded anything in literally 2 years, but it was a simple and pretty obvious mistake. thanks for all your help, nick On Jul 9, 11:30 am, Friðrik Már Jónsson wrote: > Previously, I wrote: > >> P.S. While this is a fairly obvious problem it's usually a good > >

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Friðrik Már Jónsson
Previously, I wrote: P.S. While this is a fairly obvious problem it's usually a good idea to post working code and a traceback when requesting help. Nick wrote: thanks for spotting the obvious errors, its my 2nd day programming python in about 3 years. I'm sorry, my saying it was obvious ma

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Dave Angel
ger. Traceback (most recent call last): File "M:\Programming\Python\sources\dummy\echo2.py", line 21, in print len(fields) TypeError: 'int' object is not callable DaveA -- http://mail.python.org/mailman/listinfo/python-list

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Bruno Desthuilliers
Nick a écrit : I've seen a lot of posts on this problem, but none seems to help. Here is the code: /code file = open(prefix1) shadows the builtin 'file' type. text = file.readlines() len = len(text) shadows the builtin 'len' function. fields = text[1].split() num_rows = int(fields[1]) n

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Nick
redefined two built-in functions "file" and "len" in the first three > lines. > This is usually considered poor practice. Stick to meaningless variable names, > it's safer (only joking). > > TypeError: 'int' object is not callable". This me

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Richard Brodie
his is usually considered poor practice. Stick to meaningless variable names, it's safer (only joking). TypeError: 'int' object is not callable". This means that something you thought was a function is in fact an integer. It's helpful to post/look at the line number of the

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Friðrik Már Jónsson
Look at: len = len(text) You're overriding `len` (a built-in method), with an integer (`len(text)`). You then call: for i in range(len(fields)): But `len` is no longer a callable, but merely an integer. Regards, Friðrik Már P.S. While this is a fairly obvious problem it's usually a g

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Lutz Horn
Hi, Nick schrieb: > I've seen a lot of posts on this problem, but none seems to help. Could you please post a sample input file and the exact error message? Thanks Lutz -- Strike Out ⇒ http://www.fourmilab.ch/documents/strikeout -- http://mail.python.org/mailman/listinfo/python-list

gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Nick
I've seen a lot of posts on this problem, but none seems to help. Here is the code: /code file = open(prefix1) text = file.readlines() len = len(text) fields = text[1].split() num_rows = int(fields[1]) num_cols = int(fields[2]) U1_matrix = [] print fields print repr(fields) print len(fields) fo

Re: "TypeError: 'int' object is not callable"

2009-06-02 Thread Richard Brodie
"Visco Shaun" wrote in message news:mailman.966.1243852864.8015.python-l...@python.org... > when I was executing the below code I got "TypeError: 'int' object is > not callable" exception. Why is it so? > > if type(c) == type(ERROR): You've p

Re: "TypeError: 'int' object is not callable"

2009-06-01 Thread Rhodri James
On Mon, 01 Jun 2009 11:40:50 +0100, Visco Shaun wrote: when I was executing the below code I got "TypeError: 'int' object is not callable" exception. Why is it so? if type(c) == type(ERROR): c can be a string or an integer representing an error In the absence of the re

Re: "TypeError: 'int' object is not callable"

2009-06-01 Thread Chris Rebert
On Mon, Jun 1, 2009 at 3:40 AM, Visco Shaun wrote: > when I was executing the below code I got "TypeError: 'int' object is > not callable" exception. Why is it so? > > if type(c) == type(ERROR): > > c can be a string or an integer representing an error Pleas

Re: "TypeError: 'int' object is not callable"

2009-06-01 Thread Andre Engels
On Mon, Jun 1, 2009 at 12:40 PM, Visco Shaun wrote: > when I was executing the below code I got "TypeError: 'int' object is > not callable" exception. Why is it so? > > if type(c) == type(ERROR): > > c can be a string or an integer representing an error C

"TypeError: 'int' object is not callable"

2009-06-01 Thread Visco Shaun
when I was executing the below code I got "TypeError: 'int' object is not callable" exception. Why is it so? if type(c) == type(ERROR): c can be a string or an integer representing an error -- Thanks & Regards visco -- http://mail.python.org/mailman/listinfo/python-list

Re: "'int' object is not iterable" iterating over a dict

2008-10-05 Thread Diez B. Roggisch
mmiikkee13 schrieb: a_list = range(37) list_as_dict = dict(zip(range(len(a_list)), [str(i) for i in a_list])) for k, v in list_as_dict: ... print k, v ... Traceback (most recent call last): File "", line 1, in TypeError: 'int' object is not iterable What 'int&

Re: "'int' object is not iterable" iterating over a dict

2008-10-05 Thread Alex_Gaynor
ecent call last): >   File "", line 1, in > TypeError: 'int' object is not iterable > > What 'int' object is this referring to? I'm iterating over a dict, not > an int. It thinks you are trying to unpack the first item, you mean to be doing for k, v in list_as_dict.iteritems() -- http://mail.python.org/mailman/listinfo/python-list

"'int' object is not iterable" iterating over a dict

2008-10-05 Thread mmiikkee13
>>> a_list = range(37) >>> list_as_dict = dict(zip(range(len(a_list)), [str(i) for i in a_list])) >>> for k, v in list_as_dict: ... print k, v ... Traceback (most recent call last): File "", line 1, in TypeError: 'int' object is not iterab

Re: TypeError: 'int' object is not callable for max(2,3)

2007-07-25 Thread Steve Holden
Arash Arfaee wrote: > Hi all, > I have a problem. if I enter max(2,3) before I run my program in command > line it returns 3. However if I start to debug my program, I have this > error: > > [Dbg]>>> max(2,3) > Traceback (most recent call last): > File

TypeError: 'int' object is not callable for max(2,3)

2007-07-25 Thread Arash Arfaee
Hi all, I have a problem. if I enter max(2,3) before I run my program in command line it returns 3. However if I start to debug my program, I have this error: [Dbg]>>> max(2,3) Traceback (most recent call last): File "", line 1, in TypeError: 'int' object is not c

Re: 'int' object is not callable in an threaded app

2007-05-22 Thread king kikapu
> It appears that worker.start gets set to the result of > count.ui.spFrom.value(). If that result is an int, then worker.start() is > going to generate the TypeError you received. Did you actually mean to call > worker.run() instead? > > --- > -Bill Hamilton Some friend pointed out to me an ho

RE: 'int' object is not callable in an threaded app

2007-05-22 Thread Hamilton, William
spinboxes) > > I was given help if how to setup correctly the Signals and Slots > mechanism but i am stuck at this Python error at the "worker.start()" > command: > > TypeError: 'int' object is not callable > > > Before i go and suicide, has anybo

'int' object is not callable in an threaded app

2007-05-22 Thread king kikapu
i am stuck at this Python error at the "worker.start()" command: TypeError: 'int' object is not callable Before i go and suicide, has anybody an idea what is going on here ??... import sys from PyQt4 import QtCore, QtGui from calculatorform_ui import Ui_CalculatorForm

Re: TypeError: 'int' object is not callable

2007-03-22 Thread AWasilenko
condition which prevented it from > > fulfilling the request. > > > Traceback (most recent call last): > > File "/home2/awasilenko/lib/python2.4/cherrypy/_cprequest.py", line > > 342, in respond > > cherrypy.response.body = self.handler() > > File &q

Re: TypeError: 'int' object is not callable

2007-03-22 Thread Dan Bishop
andler() > File "/home2/awasilenko/lib/python2.4/cherrypy/_cpdispatch.py", line > 15, in __call__ > return self.callable(*self.args, **self.kwargs) > File "/home2/awasilenko/webapps/cp/site.py", line 7, in index > return selection.input() > File

TypeError: 'int' object is not callable

2007-03-22 Thread AWasilenko
quot;, line 342, in respond cherrypy.response.body = self.handler() File "/home2/awasilenko/lib/python2.4/cherrypy/_cpdispatch.py", line 15, in __call__ return self.callable(*self.args, **self.kwargs) File "/home2/awasilenko/webapps/cp/site.py", line 7, in index return sele