Skip to content

use with argparse #3

@janash

Description

@janash

Hello! This issue is concerning your comments on using argparse. I haven't run your code, but here are a few comments.

I see you using global debug a lot. This should be necessary. The variable debug as declared should already be "global" (ie readable inside of the functions). Since you are only reading it, I believe you do not need debug. This should be true when the file is run as a script whether or not it is in __main__. However, if the definition is in __main__ and you run with pytest (or run functions from an import), debug will not be defined, so tests will fail.

You might try putting everything with argparse in __main__ and adding a default argument (debug=False) to all of your function definitions which can be overridden with the value from argparse when the script is run. This way, debug is defined automatically to be False. When you use it, you will call it with the appropriate values (in __main__, this would be debug=args.debug).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions