to make the question more clear, I am using Argparse to receive two optional arguments. I only want to use them if both are given, but I do not want to require them.
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--destination", help="set the destination directory or disk.",)
parser.add_argument("-s", "--source", help="set the source directory or disk.")
What I was trying to do is check if either of those two was other than None, and from there run my code.
As I am here I guess you can figure out that I was unsuccesful. I don't think giving my horrible attempts at doing this is useful to anyone, since there is probably a uniform answer I couldn't find by Googling.
Thanks for looking at my question and possible answering it!
argparseto reject command lines if one is None and the other isn't, or do you just want an if/then?required=Truei.e.parser.add_argument("-s", "--source", required=True, help="set the source directory or disk.")but this isn't pythonic for '-' parametersifversion is the only option. Maybe using a custom error as shown here: stackoverflow.com/a/8107776/2337736