[Baypiggies] Input in hex format

Chris Rebert cvrebert at gmail.com
Thu Aug 14 23:30:59 CEST 2008


hex_num = int(raw_input("prompt here"), 16) #allows optional leading 0X or 0x
binary_num = int(raw_input("prompt here"),2)

Or generally:
num = int("number as string", base)

- Chris

========
Follow the path of the Iguana...
Rebertia: http://rebertia.com
Blog: http://blog.rebertia.com


On Thu, Aug 14, 2008 at 2:23 PM, David Elsen <elsen.david08 at gmail.com> wrote:
>
> Greetings all,
>
> One very simple question please.
>
> I want to assign hex value to one of my class field.
>
> Can someone please tell me how can give hex and binary input to one of my
> class field?
>
> By default, it is taking in decimal and that is expected. After all code
> should be for human not for machines.
>
> thanks,
> david
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies
>


More information about the Baypiggies mailing list