This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lopgok
Recipients lopgok
Date 2008-12-08.03:29:29
SpamBayes Score 1.3532842e-05
Marked as misclassified No
Message-id <1228706970.47.0.163581858877.issue4588@psf.upfronthosting.co.za>
In-reply-to
Content
I want to make my own data of types bytes in order to write it out.
For example, I want to write out the bytes 0..9

#!/usr/bin/env python3.0
foo = b''
for i in range (0,10):
    foo += i
#sys.stdout.buffer.write(foo)

Here is the error:
Traceback (most recent call last):
  File "./x.py", line 4, in <module>
    foo += i
TypeError: can't concat bytes to int

I cannot find any function to convert the int i into something
that I can append to foo. I tried chr, which produced a string
typeerror. byte() was not defined. There must be a way to convert
an integral value to a bytes type.
History
Date User Action Args
2008-12-08 03:29:30lopgoksetrecipients: + lopgok
2008-12-08 03:29:30lopgoksetmessageid: <1228706970.47.0.163581858877.issue4588@psf.upfronthosting.co.za>
2008-12-08 03:29:29lopgoklinkissue4588 messages
2008-12-08 03:29:29lopgokcreate