Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100410

Re: List of integers

From Terry Reedy <tjreedy@udel.edu>
Newsgroups comp.lang.python
Subject Re: List of integers
Date 2015-12-14 04:56 -0500
Message-ID <mailman.5.1450086999.14916.python-list@python.org> (permalink)
References <6faae197-594a-4447-b146-6f5e01185e26@googlegroups.com>

Show all headers | View raw


On 12/13/2015 7:24 PM, KP wrote:
>
>
> data = list(f.read(4))
> print data
>
> from a binary file might give

In 2.x, a binary file and a text file are not distinguished.

> ['\x10', '\x20', '\x12', '\x01']

If a 'binary' file yields strings, you must be using 2.x.

> How can I receive this instead?
> [0x10, 0x20, 0x12, 0x01]

Use python 3.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

List of integers KP <kai.peters@gmail.com> - 2015-12-13 16:24 -0800
  Re: List of integers Chris Angelico <rosuav@gmail.com> - 2015-12-14 11:32 +1100
    Re: List of integers KP <kai.peters@gmail.com> - 2015-12-13 19:11 -0800
  Re: List of integers Terry Reedy <tjreedy@udel.edu> - 2015-12-14 04:56 -0500
    Re: List of integers Steven D'Aprano <steve@pearwood.info> - 2015-12-14 21:37 +1100

csiph-web