hex

Diez B. Roggisch deets at nospam.web.de
Thu Nov 19 03:48:03 EST 2009


hong zhang schrieb:
> List,
> 
> I want to input hex number instead of int number. in type="int" in following,
> 
> parser.add_option("-F", "--forcemcs", dest="force_mcs", type="int", default=0, help="index of 11n mcs table. Default: 0.")
> 
> How can I do it?

You can't. You can get a string, and convert that with e.g.

  int("FF", 16)

Or you can extend optparse to know a new type, should be possible. That 
would have the advantage that the parser already knows about it & can 
reject faulty input.

Diez




More information about the Python-list mailing list