Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Conversation

@cmaureir
Copy link

Hello,

Since optparse is deprecated, so I did a few modifications to the code to use argparse.
The only differences are that with argparse the order of the parameters does not matter.
I added an argument called "script_file" without any minus-option (instead of a "-i/--input script_file"),
to have the same usage as optparse.

Regards

Cristian Maureira-Fredes added 2 commits September 24, 2014 12:10
Optparse is deprecated, so I did a few modifications
to the code to use this new module.
The only differences are that with argparse the order
of the parameters does not matter.
I place an argument called "script_file" to have the
same initial structure of optparse
(istead of a "-i/--input script_file")

Signed-off-by: Cristian Maureira-Fredes <[email protected]>
Signed-off-by: Cristian Maureira-Fredes <[email protected]>
@rkern
Copy link
Owner

rkern commented Sep 24, 2014

Thanks! The main problem is that there is no way to pass command-line arguments to the script being profiled. This is why I used optparse at the time; the allow_interspersed_args is a cheap and cheerful (albeit not entirely proper) way to allow this. There are ways to do this with argparse, with some effort.

@cmaureir
Copy link
Author

Ah true, you are right, I will take a look of this issue, if I manage to do it I will submit a new pull request.
You can remove this one :P

Regards

@rkern
Copy link
Owner

rkern commented Sep 24, 2014

Thanks! The less-than-ideal solution is just to add an extra nargs='*' script_args argument, but this will force users to put a -- between the script and any --options meant for the script to prevent the kernprof parser from treating them as kernprof options.

Personally, I am inclined to just leave it as-is for now. While deprecated, optparse is not going to be removed from the standard library, as far as I've followed the discussion. It's just not the state-of-the-art recommendation for new projects, and new features probably won't be added to it. click has similar problems with argparse and has also chosen to stick with optparse.

That said, if you can find another reason to use argparse, something that it handles better than optparse without introducing more problems, be my guest.

@rkern rkern closed this Sep 24, 2014
@caethan caethan mentioned this pull request Oct 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants