pack an integer into a string

superpollo user at
Fri Jul 24 18:28:09 EDT 2009

is there a pythonic and synthetic way (maybe some standard module) to 
"pack" an integer (maybe a *VERY* big one) into a string? like this:

  >>> number = 252509952
  >>> hex(number)

so i would like a string like '\xf0\xcf\xf0\x00'

i wrote some code to do it, so ugly i am ashamed to post :-(

i tried xdrlib, but does not quite do what i mean...


More information about the Python-list mailing list