Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65515 > unrolled thread

TypeError: 'list' object is not callable

Started bywilsonmonde@gmail.com
First post2014-02-06 00:01 -0800
Last post2014-02-06 00:53 -0800
Articles 6 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  TypeError: 'list' object is not callable wilsonmonde@gmail.com - 2014-02-06 00:01 -0800
    Re: TypeError: 'list' object is not callable Peter Otten <__peter__@web.de> - 2014-02-06 09:22 +0100
      Re: TypeError: 'list' object is not callable wilsonmonde@gmail.com - 2014-02-06 01:11 -0800
        Re: TypeError: 'list' object is not callable Asaf Las <roegltd@gmail.com> - 2014-02-06 01:24 -0800
        Re: TypeError: 'list' object is not callable Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-02-06 11:34 +0200
    Re: TypeError: 'list' object is not callable Gary Herron <gary.herron@islandtraining.com> - 2014-02-06 00:53 -0800

#65515 — TypeError: 'list' object is not callable

Fromwilsonmonde@gmail.com
Date2014-02-06 00:01 -0800
SubjectTypeError: 'list' object is not callable
Message-ID<38411b43-0f2b-451c-a4ac-1379b5cc8607@googlegroups.com>
import csv

date1 = []
open = []
high = []
low = []
close = []
data = []
with open("C:/Documents and Settings/wilson/My Documents/Downloads/execution.csv", "rb") as csvfile:
	fastreader = csv.reader(csvfile, delimiter = ",", skipinitialspace=True)
	count = 0
	for row in fastreader:
		date1.append(row[0])
		count = count + 1


TypeError: 'list' object is not callable

[toc] | [next] | [standalone]


#65521

FromPeter Otten <__peter__@web.de>
Date2014-02-06 09:22 +0100
Message-ID<mailman.6439.1391674965.18130.python-list@python.org>
In reply to#65515
wilsonmonde@gmail.com wrote:

> TypeError: 'list' object is not callable

Hint:

> open = []

[...]

> with open(..., "rb") as csvfile:

[toc] | [prev] | [next] | [standalone]


#65525

Fromwilsonmonde@gmail.com
Date2014-02-06 01:11 -0800
Message-ID<21fdab4b-8b08-4f18-bcd4-678eb04b03ac@googlegroups.com>
In reply to#65521
Peter Otten於 2014年2月6日星期四UTC+8下午4時22分45秒寫道:
> wilsonmonde@gmail.com wrote:
> 
> 
> 
> > TypeError: 'list' object is not callable
> 
> 
> 
> Hint:
> 
> 
> 
> > open = []
> 
> 
> 
> [...]
> 
> 
> 
> > with open(..., "rb") as csvfile:


i follow in
http://www.dyinglovegrape.com/data_analysis/part1/1da3.php

still have error

what is the correct writing?

[toc] | [prev] | [next] | [standalone]


#65526

FromAsaf Las <roegltd@gmail.com>
Date2014-02-06 01:24 -0800
Message-ID<84d210a0-d78b-4aef-b971-78cde85a1254@googlegroups.com>
In reply to#65525
On Thursday, February 6, 2014 11:11:13 AM UTC+2, wilso...@gmail.com wrote:
> i follow in
> http://www.dyinglovegrape.com/data_analysis/part1/1da3.php
> still have error
> what is the correct writing?

give another name to list 'open' at line 'open= []'
change it to dopen or whatever. you make name conflict with 
builtin function open(). 
Names can't be used freely.

[toc] | [prev] | [next] | [standalone]


#65527

FromJussi Piitulainen <jpiitula@ling.helsinki.fi>
Date2014-02-06 11:34 +0200
Message-ID<qottxcca8kf.fsf@ruuvi.it.helsinki.fi>
In reply to#65525
wilsonmonde@gmail.com writes:
> Peter Otten wrote:
> > wilsonmonde@gmail.com wrote:
> > 
> > > TypeError: 'list' object is not callable
> > 
> > Hint:
> > 
> > > open = []
> > 
> > [...]
>
> > > with open(..., "rb") as csvfile:
> 
> i follow in
> http://www.dyinglovegrape.com/data_analysis/part1/1da3.php
> 
> still have error
> 
> what is the correct writing?

One way:

   # open = []
   with open(..., "rb") as csvfile:

Commenting out the assignment statement prevents it from doing the
damage before you try to access the original value of open.

Another way:

   with [](..., "rb") as csvfile:

This doesn't work any better but it makes the error stand out.

Yet another way:

   avaa = open
   open = []
   with avaa(..., "rb") as csvfile:

That is, save the original value of open in another variable, which I
here called avaa.

The best way is to omit the whole assignment altogether. Were you
using the list called open for something?

Oh, one more way!

   with open(..., "rb") as csvfile:
      ...
   open = []

That is, only shoot yourself in the foot after the work has been done!
Though, really, best not do it at all. The page you referred to,
doesn't.

[toc] | [prev] | [next] | [standalone]


#65524

FromGary Herron <gary.herron@islandtraining.com>
Date2014-02-06 00:53 -0800
Message-ID<mailman.6440.1391677305.18130.python-list@python.org>
In reply to#65515

[Multipart message — attachments visible in raw view] — view raw

On 02/06/2014 12:01 AM, wilsonmonde@gmail.com wrote:
> import csv
>
> date1 = []
> open = []
> high = []
> low = []
> close = []
> data = []
> with open("C:/Documents and Settings/wilson/My Documents/Downloads/execution.csv", "rb") as csvfile:
> 	fastreader = csv.reader(csvfile, delimiter = ",", skipinitialspace=True)
> 	count = 0
> 	for row in fastreader:
> 		date1.append(row[0])
> 		count = count + 1
>
>
> TypeError: 'list' object is not callable

I'd be glad to help, but I'm not interested in guessing.  Pleas take the 
time to tell us what line produced that error?  That is: cut and paste 
the *full* traceback instead of hiding useful information when you are 
asking for help.

Gary Herron

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web