Re: newbie question



"Bermi" <bermi7@xxxxxxxxx> wrote:

>i have this program
>===================
>from sys import *
>import math
>import math, Numeric
>from code import *
>from string import *
>from math import *
>from dataSet import *
>from string import *

I know you said you are a newbie. That means there is still time for you
to learn to do things the proper way. Change all of that to:

import sys
import math
import Numeric
import dataSet

You don't need to import string at all, and you will probably never use
"code".


>def drawAsciiFile():
> _fileName=str(argv[1])

argv is already an array of strings. The "str" is useless.

> __localdataSet=DataSet(_fileName)
>
> #_PlotCols=string.split(str(argv[2]),' ')
> #_PlotColsInt=[]
> '''for s in _PlotCols:
> _PlotColsInt.append(int(s))
> CountourPlots(__localdataSet,_PlotColsInt)
>'''
> print
> __data=__localdataSet.GetData()
> print max(__data[:,11])
>if __name__ == "__main__":
> drawAsciiFile()
>================================
>
>how i can link it to read my file examle.txt?

Instead of referring to argv inside your function, you should pass the file
name as a parameter. That way, at a later time, you can pass it file names
from sources other than argv. Also, there is no point in using leading
underscores for local variables. That's only interesting for members of
the class.

You are splitting argv[2]. Ordinarily, sys.argv has already been split.
That is, "xxx.py file 1 3 5 7" will produce 6 elements in sys.argv. If you
really want the columns as a single parameter, you'll have to use quoting:
xxx.py file "1 3 5 7"

Something like this, maybe:

def drawAsciiFile(filename, columns):
localdataSet = DataSet.DataSet( filename )
PlotCols = [int(s) for s in columns.split()]
ContourPlots( localdataSet, PlotCols )

if __name__ == "__main__":
if len(sys.argv) < 2:
print 'Usage: xxxx.py filename "3 5 7"' )
drawAsciiFile( sys.argv[1], sys.argv[2] )
--
- Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
.



Relevant Pages

  • Re: Results of the memswap() smackdown from the thread "Sorting" assignment
    ... There is no "math". ... A string with a length code can be safely assigned: ... you can shit all over people like Schildt from your perch. ...
    (comp.programming)
  • Re: General equation
    ... what the curve looks like. ... my math agrees with Pat's visualization. ... animation progress into several mathematical equations. ... bottom of the string progresses rightward as the top of the ...
    (rec.org.mensa)
  • Re: General equation
    ... what the curve looks like. ... my math agrees with Pat's visualization. ... animation progress into several mathematical equations. ... bottom of the string progresses rightward as the top of the ...
    (rec.org.mensa)
  • Re: General equation
    ... Yes, you are correct in that the resulting curve seems to resemble a hyperbola, but I prefer to think of it as a partial elipse. ... to be able to not only see the progress for myself, I wanted to be able to export my software and the animation program and quell any future arguments. ... bottom of the string progresses rightward as the top of the string progresses downward. ... That way you can challenge whatever math I am using and we both can draw on the same chalkboard. ...
    (rec.org.mensa)
  • Re: General equation
    ... It wouldn't be easy to construct at all without some additional constructions like locating the where on the string the point of interest will be located, where the string originates, and to finally give the coordinates of where that point on the string will occur. ... I would use an animation program to visually display the progress of the point through the range of motions. ... coordinates of what started as the bottom end of the line (each ... a group of college math instructors who like puzzles, ...
    (rec.org.mensa)