within the frame of a python application, I need to make calls to several of my scripts that were largely using optparse. They all have an entry point of this form :
if __name__ == '__main__':
mains(sys.argv)
I just called my main function mains thinking that my problem initially came from there. Then, the mains always start like that, as an example :
def mains( argv ):
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename", help="write result to FILE", metavar="FILE")
parser.add_option("-x", "--filter", dest="filterset", help="filters", metavar="FILTERS")
parser.add_option("-n", "--nameonly", dest="nameonly", help="nameonly", metavar="NAME_ONLY")
parser.add_option("-z", "--ignorezeros", dest="ignorezeros", help="ignorezeros", metavar="IGNORE_ZEROS")
parser.add_option("-y", "--xfilter", dest="xfilter", help="xfilter", metavar="X_FILTERS")
The argv here isn't used by optparser, I do not find how to pass it to it. From my actual principal script, I thought I could call these mains by just passing the arguments as a list. Obvioulsy, in the current state the sub scripts will always pick up the command line... How to pass the arguments myself instead ?
UPDATE : my script trying to make those calls to subcripts is called this way from the console :
start.py -df
The problem : optparse from the first subscript tells me that "d" is not a valid option, which shows it is picking the console arguments at the moment.