This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jaraco
Recipients BreamoreBoy, bethard, docs@python, eric.araujo, jaraco, paul.j3, terry.reedy, tshepang
Date 2014-07-16.20:54:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1405544044.34.0.648322350706.issue13540@psf.upfronthosting.co.za>
In-reply-to
Content
That's interesting that there's activity on this again. I had forgotten I'd filed it. It's particularly timely, as I just yesterday had this experience again. I looked at the documentation and found it inadequate for me to understand how to implement a custom action, so I went to the source to figure it out. The action I ended up creating was this one:

class SandboxAction(argparse.Action):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, nargs=0, **kwargs)

    def __call__(self, *args, **kwargs):
        cls.use()

Where 'cls' is defined in the same scope where SandboxAction was defined. I'm not sure if my documentation patch would have been sufficient to allow me to write that Action without consulting the source, but this example represents another case where that should be possible.

I haven't made any tweaks to the patch as a result of Steven's comments, so I probably could do that. I don't now when I'll have the time to do that, but I'll keep a tab to remind me to revisit the issue again.
History
Date User Action Args
2014-07-16 20:54:04jaracosetrecipients: + jaraco, terry.reedy, bethard, eric.araujo, docs@python, BreamoreBoy, tshepang, paul.j3
2014-07-16 20:54:04jaracosetmessageid: <1405544044.34.0.648322350706.issue13540@psf.upfronthosting.co.za>
2014-07-16 20:54:04jaracolinkissue13540 messages
2014-07-16 20:54:04jaracocreate