March 30th, 2004, 02:48 AM
Join Date: Feb 2004
Time spent in forums: < 1 sec
Reputation Power: 0
distinguishing between two forms of input
how can i distinguish between two form of input such as stdin and command line
python p.py < file.txt
python p.py file.txt
i tried if/else statements based on the presence of < in sys.argv but it doesn't seem to be detecting <... moreover, i dont' know want to do it based on the number of arguments (1 argument for stdin and 2 arguments for command line) as i may do it this way
cat file.txt | python p.py
i also may include other option after
python p.py < file.txt -d whatever -1 wohoo
and one more question...
how can output a file to a directory other than the current directroy... i'm pretty it is in th os module but i can't seem to find it...
file = open("input.txt", "w")
how can i output input.txt to another directory other than my current working directory...