is it bad convention to call sys.argv from somewhere besides main function in python -
I am writing a script and I have a function, call it f () , Which needs one of the command line arguments (a filename that needs to be opened) However, in the main code f () is not directly called
I'm thinking Was it bad coding conference to call sys.argv [1] directly to f () ? If I do not, then I have to give it all the work in the form of an argument which ultimately call f () .
It would be a bad practice to always believe that the needs of your function are available on the command-line- What if this code was implemented in any other way?
A function should declare the input parameter for the data that it needs.
Logic in f () instead of accessing the required sys.argv at the very least, f () Helps make more reusable.
Comments
Post a Comment