Issue
I'm parsing system arguments in my Python project using sys.argv
. At some point i had to modify the script after having written the logic that parses system args. I added a line the basically appends a string to sys.argv
so the logic that parses it won't be changed -
sys.argv.append('some string here')
Is it a bad practice to modify the system arguments after they have been created for the program ?
Solution
It is bad practice to modify sys.argv
in Python and it's equivalent in other languages.
In these situations I recommend a parsed_args
variable which has all your parsed data from sys.argv
, any default values that you would like to set, and any modifications that "middleware" would make.
Answered By - dotancohen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.