Hello folks ,I have a program in which a text file is generated as an output
eg

C:\prog\ prog -x test.txt
Right now whenever i have to read the test file i have to put its name
manually in my code.
eg
f=open("c:\\prog\\test.txt","r")

How ever i want to add the name of the test file dynamically to my program
ie , if every time i give

C:\prog\ prog -x test.txt
The filename (test.txt) automatically comes in
f=open("c:\\prog\\test.txt","r")

C:\prog\ prog -x file1.txt
f=open("c:\\prog\\file1","r")


in other words i do not want to do hard code the name of the file in my code
every time i need to read it.

I was reading about the sys module and i guess sys.argv would take the input
from the command line whenever i run the python script .

Please guide me in the right direction on how to tackle the problem.

Thanks in advance

Aditya
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to