Python magic function, how does it work? -


how magic function work (below) i.e. hex = '%032x' % self.int reason turns following value...

265631021230191344138857284998518456

into....

0033289ed88646a64b9fc63c808fd6b8

def __str__(self):     hex = '%032x' % self.int     return hex 

but should knowledge append 032x end of string 265631021230191344138857284998518456, whats going on? how does?

full code here

%x format code hex. function representing decimal value in hex.

>>> hex(265631021230191344138857284998518456) '0x33289ed88646a64b9fc63c808fd6b8' 

the full format code

'%032x' 

means represent value in hex , pad zeros on left until 32 characters wide.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

mysql - FireDac error 314 - but DLLs are in program directory -