optparse: store callback return value

sector119 sector119 at gmail.com
Sun Apr 24 07:04:43 EDT 2005


Hi

I use optparse with callback action, my callback function return some
value, but optparse does not store this value, options.callback_dest
always is None.

How can I store callback function return value or callback option value
like store action do?

I modify optparse.py Option::take_action def and add there:

value = self.callback(self, opt, value, parser, *args, **kwargs) or
value
setattr(values, dest, value)

as for STORE_ACTIONS. but I do not like to do it like this :/ Why
optparse does not do it, store return or option value, this way?




More information about the Python-list mailing list