Rhodri James rhodri at wildebst.demon.co.uk
Fri Nov 20 00:45:56 CET 2009

On Thu, 19 Nov 2009 02:29:59 -0000, hong zhang <henryzhang62 at yahoo.com>  

> 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?

Assuming you're talking about "optparse", just prefix the number with "0x"  
on the command line:

python myscript.py -F 0xDEAD

If you don't want to have to type the leading "0x", you'll either have to  
make yourself a custom type for optparse, or treat it as a string and do  
the parsing and error handling afterwards.  My recommendation is that you  
don't do this: not prefixing your constants if they aren't decimal is an  
accident waiting to happen.

Rhodri James *-* Wildebeest Herder to the Masses

More information about the Python-list mailing list