Python Forum

Full Version: hexadecimal world
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i am thinking of hacking a version of the python interpreter to use hexadecimal (which i call "cetal"), without the leading "0x", as the default everywhere. a new designation (0z) would be added for decimal.
You really like to waste time don't you.
I was very angry about the leading 0x until I have seen binascii and formatting.

In [22]: import binascii                                                        

In [23]: binascii.hexlify(b'Hello World')                                       
Out[23]: b'48656c6c6f20576f726c64'

In [24]: binascii.unhexlify(_)                                                  
Out[24]: b'Hello World'

In [25]: x = 42                                                                 

In [26]: f'{x:x}'                                                               
Out[26]: '2a'

In [27]: f'{x:010x}'                                                            
Out[27]: '000000002a'
(Apr-05-2019, 07:37 AM)Larz60+ Wrote: [ -> ]You really like to waste time don't you.
it doesn't take much time in my imaginary world (nothing to do with complex numbers).

i avoid the leading 0x where i can, such as in the cetal world. i am thinking of using 6 Greek letters for a..f: alpha, beta, sigma, delta, gamma, phi, lower case in that order. then where i need a prefix i can use chi. i would then define the use of any other letter as not taking a position (so chi can be anywhere in the digit sequence to do its thing).