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 andybuckley
Recipients andybuckley
Date 2009-02-26.14:08:18
SpamBayes Score 2.8632405e-07
Marked as misclassified No
Message-id <1235657301.0.0.570372518506.issue5374@psf.upfronthosting.co.za>
In-reply-to
Content
optparse's OptionParser takes a usage string as a constructor argument,
in which a "%prog" token is replaced with the executable name. Nice
idea, but the choice of a percent sign for token delimiter is
troublesome since it means that attempting to substitute any variables
into the usage string, e.g.

    usage = """
    %prog [options] foo bar ...
    
    Some computed info: %s""" % myinfo

gives a ValueError:

    ValueError: unsupported format character 'p' (0x70) at index 2

Maybe this ceases to be a problem with what I've heard about the
formatting re-design in Python 3.x, but it will probably continue to be
awkward for the 2.x series where the "%" operator still applies. Maybe
optparse could also use a safer token ("@prog", say), so that those of
use who would like to substitute variables into usage strings don't have
to artificially break our strings apart every time we use the program name?
History
Date User Action Args
2009-02-26 14:08:21andybuckleysetrecipients: + andybuckley
2009-02-26 14:08:20andybuckleysetmessageid: <1235657301.0.0.570372518506.issue5374@psf.upfronthosting.co.za>
2009-02-26 14:08:19andybuckleylinkissue5374 messages
2009-02-26 14:08:18andybuckleycreate