Python Twisted using argparse module

Question:

I’m building Python Twisted applications and would like to use the argparse module to parse command line options, instead of the Twisted usage.Options, which seems kind of old school.

I’d like to run the app with twistd, and am concerned about argparse interfering with twistd’s command line argument parsing. I am seeking pointers, suggestions or opinions on what I’m trying to do.

Asked By: writes_on

||

Answers:

Your twistd plugins are required to parse command-line options by providing a class with a parseOptions method that takes an argv-style list. Beyond that, what you do is up to you. If you supply a class with that method that calls into argparse, great.

Answered By: Jean-Paul Calderone
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.