[New-bugs-announce] [issue4588] Need a way to make my own bytes

jeff deifik report at bugs.python.org
Mon Dec 8 04:29:30 CET 2008


New submission from jeff deifik <jeff at jeffunit.com>:

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.

----------
components: Interpreter Core
messages: 77286
nosy: lopgok
severity: normal
status: open
title: Need a way to make my own bytes
type: crash
versions: Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4588>
_______________________________________


More information about the New-bugs-announce mailing list