Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65527
| From | Jussi Piitulainen <jpiitula@ling.helsinki.fi> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: TypeError: 'list' object is not callable |
| Date | 2014-02-06 11:34 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <qottxcca8kf.fsf@ruuvi.it.helsinki.fi> (permalink) |
| References | <38411b43-0f2b-451c-a4ac-1379b5cc8607@googlegroups.com> <mailman.6439.1391674965.18130.python-list@python.org> <21fdab4b-8b08-4f18-bcd4-678eb04b03ac@googlegroups.com> |
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web