The goal:
- take an argument in argparse,
- test if that argument is true
- if true, write a file with the name specified after that argument
Eg: in the command line:
$ python printfile.py --out_arg fileOutput.txt
... would produce a fileOutput.txt in the same directory as printfile.py
Code:
def parse_arguments():
options = parse_arguments()
#output arguments
parser.add_argument("--out_arg", action='store', default=False, dest='out_arg',
help="""Output file """)
def print_output(seqID, seq, comm):
# "a" append is used since this is the output of a for loop generator
if options.out_arg
outputfh = open(options.out_33,"a")
outputfh.write("@{}\n{}\n{}\n+".format(seqID, seq, comm))
else:
sys.stderr.write("ERR: sys.stdin is without sequence data")
Yet, when I call print_output from def main() -not shown- passing in my tuple of interest (seqID, seq, comm), no file is written, and no error message given. Is it the argparse arguments not storing the inputed file as the dest? Is it the use of a file handle when trying write?