Helll I am trying to figure out how to enter arguments throught he command line for a program I have created that is already working. I just want to adapt it to work at the command line. Here is the code.
I would like to make it so that the user is never asked to enter anything just so that they can enter arguments from the c:\ for example the entering of carguments would look like this
c:\2535358.68,2 3689.36,1423.35 ,8236.32,2000,p oints.txt
basically in the above there are six arguments entered, X and Y coordinates for the upper left value, X and Y coordinates for the lower right value, the 2000 is for the amount of pionts the user wishs to generate and the points.txt is the file they wisht to be created where these points will be stored? I have looked at some command line parsing but it's rather technical. Any help would be great thanks.
Code:
import random
print\
"""
#---------------#
# RPG 1.0 #
#---------------#
Welcome to Random_Point_Generator 1.0 (RPG 1.0),RPG is very simple to use.
RPG generates a series of random points and writes these points to a .xyz
file. In order to generate these points RPG asks the user to input two sets
of coordinates and the number of points the user wishs to generate.RPG first
asks for an upper_left and a lower_right set of coordinates.It will then ask
the user for the number of points that the they wishs it to generate.
Random points will be generated within the bounds of the upper_left and
lower_right coordinate values.The program terminates when the user has
finished entering their xLR and yLR values.
"""
print "\nPlease enter the upper left coordinates\n"
xUL = float(raw_input("enter your x value: "))
yUL = float(raw_input("enter you y value: "))
print "\nPlease enter the lower right coordinates\n"
xLR = float(raw_input("enter your x value: "))
yLR = float(raw_input("enter your y value: "))
points = int(raw_input("\n\nHow many points do you want generated? "))
f = open(r'points.xyz', 'w')
f.writelines(['%9.2f%14.2f\n' % (random.uniform(xUL,xLR),random.uniform(yLR,yUL))for _ in range(points)])
f.close()
print '\nThanks for using RPG 1.0, your "points.xyz" file should now have been created.'
raw_input("\nPress Enter to exit.")
c:\2535358.68,2 3689.36,1423.35 ,8236.32,2000,p oints.txt
basically in the above there are six arguments entered, X and Y coordinates for the upper left value, X and Y coordinates for the lower right value, the 2000 is for the amount of pionts the user wishs to generate and the points.txt is the file they wisht to be created where these points will be stored? I have looked at some command line parsing but it's rather technical. Any help would be great thanks.
Comment