The Python script that I want to use (called snakefood ) usually runs from the command line and takes command line arguments, for example
snakefood
sfood /path/to/my/project
Command line arguments are parsed in the gendeps.py file using optparse . However, I want to use the snakefood module from another script. Is there a way that I can somehow make fun of passing command line arguments to snakefood or a way to rewrite gendeps.py so that it no longer depends on optparse ?
optparse
gendeps.py
You can always assign a new sys.argv list:
sys.argv
import sys sys.argv = ['programname', '-iq', '-q', directory] gendeps.gendeps()
optparse uses sys.argv[1:] as input, unless explicit arguments are passed.
sys.argv[1:]
Source: https://habr.com/ru/post/988550/More articles:Optimization Algorithm for Calculating Multiplier and Divisor Values - c ++Return an optional value in getter, providing an optional value in setter - setterSwift: termination with an uncaught exception of type NSException - iosAnimation hiding the status bar without changing the height UINavigationController - iosWhen and how to initialize a const variable by default? - c ++Why are my non-CRT applications interrupted at startup? - windowsColor selection does not work with undo and redo - androidCalculate energy for each frequency band around frequency F of interest to Python - pythonCreating three columns of text aligned at the same height or in a row all the time, even when resizing a window - htmlhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/988555/when-is-too-much-async-and-await-should-all-methods-return-task&usg=ALkJrhgHEjB2lLOVHm5DiPb2Evsod4M0LwAll Articles