[Tutor] unsupported operand

Alan Gauld alan.gauld at btinternet.com
Mon Dec 19 01:28:54 CET 2011


On 18/12/11 22:35, stm atoc wrote:
> Well, I tried to  check and I do not have that problem any more..but i
> have the clear script as follows and a couple of question regarding to
> this:
>
> # coding: utf-8
> from pylab import *
> import numpy
> import matplotlib.pyplot as pyplot
> import matplotlib.mlab as mlab
> #tmax=360
>
> with open("ourtest_out.list", "r") as f:
>     t = numpy.array([float(v) for v in f.readline().split()[1:]])
>
> for t, filename in enumerate("ourtest_out.list"):
> 	a = numpy.loadtxt("ourtest_out.list", skiprows=3)

You do realize that you are throwing away the t that you created above?
And I'm pretty sure this loop is not doing what you think it is...
Lets try an experiment at the >?>> prompt:

 >>> for t,f in enumerate('testing'):
...    print t,f
...
0 t
1 e
2 s
3 t
4 i
5 n
6 g


Is that what you would have expected?


> Conc=[]
> Conc.append(a[:,200])

What is a?

> plot(Conc,t)
> show()

HTH

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list