Neal Becker wrote: > I generally enjoy argparse, but one thing I find rather > ugly and unpythonic. > > parser.add_argument ('--plot', action='store_true') > > Specifying the argument 'action' as a string is IMO ugly.
It isn't ideal, but having to grab constants from the module isn't ideal either. Using a string here allows argparse (and optparse before it) to spit out an explicit "unknown action" message. Using named constants a typo would just get you a generic NameError instead. With variable names only being checked at runtime, you wouldn't get the static name checking that is the primary benefit of using named constants in less dynamic languages. So, agreed that using strings isn't pretty, but there aren't any great alternatives available. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia --------------------------------------------------------------- _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com