On Sep 30, 2009, at 11:39 AM, Steven Bethard wrote: > Thanks for the clarification. I generally like this approach, though > it's not so convenient for argparse which already takes format strings > like this:: > > parser = ArgumentParser(usage='%(prog)s [--foo]') > parser.add_argument( > '--foo', type=int, default=42, > help='A foo of type %(type)s, defaulting to %(42)s) > > That is, existing keyword arguments that already have good names (and > are pretty much always used as keyword arguments) take format strings. > I'm not sure that changing the name of usage= or help= here is really > an option. Ah right. > I guess in this case I'm stuck with something like Benjamin's > suggestion of adding an additional flag to control which type of > formatting, and the corresponding 4 versions of cleanup. Ew. I missed Benjamin's suggestion, but in this case I would say add a flag to ArgumentParser. I'm either going to want {} formatting all or nothing. E.g. import argparse parser = ArgumentParser(usage='{prog} [--foo]', format=argparse.BRACES) parser.add_argument( '--foo', type=int, default=42, help='A foo of type {type}, defaulting to {42}') (although that last looks weird ;). -Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 832 bytes Desc: This is a digitally signed message part URL: <http://mail.python.org/pipermail/python-dev/attachments/20090930/7caccaf5/attachment.pgp>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4