Re: read text file byte by byte

2009-12-16 Thread Nobody
On Mon, 14 Dec 2009 21:37:33 -0300, Gabriel Genellina wrote: >> There are no file objects in 3.x. The file() function no longer >> exists. The return value from open(), will be an instance of >> _io. depending upon the mode, e.g. _io.TextIOWrapper for 'r', >> _io.BufferedReader for 'rb', _io.Buffe

Re: read text file byte by byte

2009-12-15 Thread sjdevn...@yahoo.com
On Dec 14, 11:44 pm, Terry Reedy wrote: > On 12/14/2009 7:37 PM, Gabriel Genellina wrote: > > > > > En Mon, 14 Dec 2009 18:09:52 -0300, Nobody escribió: > >> On Sun, 13 Dec 2009 22:56:55 -0800, sjdevn...@yahoo.com wrote: > > >>> The 3.1 documentation specifies that file.read returns bytes: > > >>

Re: read text file byte by byte

2009-12-15 Thread daved170
On 13 דצמבר, 22:39, Dennis Lee Bieber wrote: > On Sat, 12 Dec 2009 22:15:50 -0800 (PST), daved170 > declaimed the following in gmane.comp.python.general: > > > Thank you all. > > Dennis I really liked you solution for the issue but I have two > > question about it: > > 1) My origin file is Text f

Re: read text file byte by byte

2009-12-14 Thread Terry Reedy
On 12/14/2009 7:37 PM, Gabriel Genellina wrote: En Mon, 14 Dec 2009 18:09:52 -0300, Nobody escribió: On Sun, 13 Dec 2009 22:56:55 -0800, sjdevn...@yahoo.com wrote: The 3.1 documentation specifies that file.read returns bytes: Does it need fixing? There are no file objects in 3.x. The fil

Re: read text file byte by byte

2009-12-14 Thread sjdevn...@yahoo.com
On Dec 14, 4:09 pm, Nobody wrote: > On Sun, 13 Dec 2009 22:56:55 -0800, sjdevn...@yahoo.com wrote: > > The 3.1 documentation specifies that file.read returns bytes: > > Does it need fixing? > > There are no file objects in 3.x. Then the documentation definitely needs fixing; the excerpt I posted

Re: read text file byte by byte

2009-12-14 Thread Gabriel Genellina
En Mon, 14 Dec 2009 18:09:52 -0300, Nobody escribió: On Sun, 13 Dec 2009 22:56:55 -0800, sjdevn...@yahoo.com wrote: The 3.1 documentation specifies that file.read returns bytes: Does it need fixing? There are no file objects in 3.x. The file() function no longer exists. The return value f

Re: read text file byte by byte

2009-12-14 Thread Nobody
On Mon, 14 Dec 2009 03:14:11 +, MRAB wrote: >>> You originally stated that you want to "scramble" the bytes -- if >>> you mean to implement some sort of encryption algorithm you should know >>> that most of them work in blocks as the "key" is longer than one byte. >> >> Block ciphers work

Re: read text file byte by byte

2009-12-14 Thread Nobody
On Sun, 13 Dec 2009 22:56:55 -0800, sjdevn...@yahoo.com wrote: > The 3.1 documentation specifies that file.read returns bytes: > Does it need fixing? There are no file objects in 3.x. The file() function no longer exists. The return value from open(), will be an instance of _io. depending upon t

Re: read text file byte by byte

2009-12-14 Thread sjdevn...@yahoo.com
On Dec 14, 1:57 pm, Dennis Lee Bieber wrote: > On Sun, 13 Dec 2009 22:56:55 -0800 (PST), "sjdevn...@yahoo.com" > declaimed the following in > gmane.comp.python.general: > > > > > > > > > The 3.1 documentation specifies that file.read returns bytes: > > > file.read([size]) > >     Read at most siz

Re: read text file byte by byte

2009-12-13 Thread sjdevn...@yahoo.com
On Dec 13, 5:56 pm, "Rhodri James" wrote: > On Sun, 13 Dec 2009 06:44:54 -, Steven D'Aprano   > > wrote: > > On Sat, 12 Dec 2009 22:15:50 -0800, daved170 wrote: > > >> Thank you all. > >> Dennis I really liked you solution for the issue but I have two question > >> about it: > >> 1) My origin

Re: read text file byte by byte

2009-12-13 Thread MRAB
Nobody wrote: On Sun, 13 Dec 2009 12:39:26 -0800, Dennis Lee Bieber wrote: You originally stated that you want to "scramble" the bytes -- if you mean to implement some sort of encryption algorithm you should know that most of them work in blocks as the "key" is longer than one byte. B

Re: read text file byte by byte

2009-12-13 Thread Nobody
On Sun, 13 Dec 2009 12:39:26 -0800, Dennis Lee Bieber wrote: > You originally stated that you want to "scramble" the bytes -- if > you mean to implement some sort of encryption algorithm you should know > that most of them work in blocks as the "key" is longer than one byte. Block ciphers w

Re: read text file byte by byte

2009-12-13 Thread Rhodri James
On Sun, 13 Dec 2009 06:44:54 -, Steven D'Aprano wrote: On Sat, 12 Dec 2009 22:15:50 -0800, daved170 wrote: Thank you all. Dennis I really liked you solution for the issue but I have two question about it: 1) My origin file is Text file and not binary That's a statement, not a question

Re: read text file byte by byte

2009-12-13 Thread Tim Chase
Grant Edwards wrote: If it's a binary file... OK, but... what is a "binary" file? One containing data encoded in base-2. Or one of a system of two files that orbits around a common center of mass? So if you see two files orbiting around a cathedral, they're binary files. f.open('binaryf

Re: read text file byte by byte

2009-12-13 Thread Grant Edwards
On 2009-12-13, Michel Claveau - MVP wrote: > Hi! > >> If it's a binary file... > > OK, but... what is a "binary" file? One containing data encoded in base-2. -- Grant -- http://mail.python.org/mailman/listinfo/python-list

Re: read text file byte by byte

2009-12-13 Thread Chris Rebert
On Sun, Dec 13, 2009 at 12:20 AM, Michel Claveau - MVP wrote: > Hi! > >> If it's a binary file... > > OK, but... what is a "binary" file? http://en.wikipedia.org/wiki/Binary_file Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: read text file byte by byte

2009-12-13 Thread Michel Claveau - MVP
Hi! > If it's a binary file... OK, but... what is a "binary" file? @+ -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: read text file byte by byte

2009-12-12 Thread Dave Angel
daved170 wrote: On Dec 13, 2:34 am, Dennis Lee Bieber wrote: On Sat, 12 Dec 2009 10:46:01 +0100, census declaimed the following in gmane.comp.python.general: def scramble (a): return (a + 13) % 256 I'll see your modulo rot 13 and raise with a exclusive or... -=-=-=

Re: read text file byte by byte

2009-12-12 Thread Lie Ryan
On 12/13/2009 5:15 PM, daved170 wrote: Thank you all. Dennis I really liked you solution for the issue but I have two question about it: 1) My origin file is Text file and not binary 2) I need to read each time 1 byte. I didn't see that on your example code. That's where you're confusing things

Re: read text file byte by byte

2009-12-12 Thread Steven D'Aprano
On Sat, 12 Dec 2009 22:15:50 -0800, daved170 wrote: > Thank you all. > Dennis I really liked you solution for the issue but I have two question > about it: > 1) My origin file is Text file and not binary That's a statement, not a question. > 2) I need to read each time 1 byte. f = open(filena

Re: read text file byte by byte

2009-12-12 Thread daved170
On Dec 13, 2:34 am, Dennis Lee Bieber wrote: > On Sat, 12 Dec 2009 10:46:01 +0100, census > declaimed the following in gmane.comp.python.general: > > > > > def scramble (a): return (a + 13) % 256 > >         I'll see your modulo rot 13 and raise with a exclusive or... > > -=-=-=-=- > > import sys

Re: read text file byte by byte

2009-12-12 Thread Tim Chase
Steven D'Aprano wrote: 2) Should I use streams? What do you mean by "streams"? they're what come out of proton packs...just don't cross them. It would be bad. -tkc (I suspect the OP is a Java/C++ programmer where "streams" are somewhat akin to generators, but less powerful; so the answer

Re: read text file byte by byte

2009-12-12 Thread Rhodri James
On Sat, 12 Dec 2009 11:14:13 -, census wrote: Steven D'Aprano wrote: On Sat, 12 Dec 2009 10:35:55 +0100, census wrote: I've got some questions - 1) How do I read the file byte by byte 2) Should I use streams? If so and I get my entire scrambled text in stream can I just write it to th

Re: read text file byte by byte

2009-12-12 Thread census
Steven D'Aprano wrote: > On Sat, 12 Dec 2009 10:35:55 +0100, census wrote: > >>> I've got some questions - >>> 1) How do I read the file byte by byte 2) Should I use streams? If so >>> and I get my entire scrambled text in stream can I just write it to the >>> binary file? >>> >>> Thanks >>> Dave

Re: read text file byte by byte

2009-12-12 Thread Steven D'Aprano
On Fri, 11 Dec 2009 23:16:42 -0800, daved170 wrote: > Hello everybody, > I need to read a text file byte after byte. Eache byte is sent to a > function that scramble it and I need to write the result to binary file. > > I've got some questions - > 1) How do I read the file byte by byte f = open

Re: read text file byte by byte

2009-12-12 Thread Steven D'Aprano
On Sat, 12 Dec 2009 10:35:55 +0100, census wrote: >> I've got some questions - >> 1) How do I read the file byte by byte 2) Should I use streams? If so >> and I get my entire scrambled text in stream can I just write it to the >> binary file? >> >> Thanks >> Dave > > f = open ("binaryfile", "r")

Re: read text file byte by byte

2009-12-12 Thread census
daved170 wrote: > Hello everybody, > I need to read a text file byte after byte. > Eache byte is sent to a function that scramble it > and I need to write the result to binary file. > > I've got some questions - > 1) How do I read the file byte by byte > 2) Should I use streams? If so and I get my

Re: read text file byte by byte

2009-12-12 Thread census
daved170 wrote: > Hello everybody, > I need to read a text file byte after byte. > Eache byte is sent to a function that scramble it > and I need to write the result to binary file. > > I've got some questions - > 1) How do I read the file byte by byte > 2) Should I use streams? If so and I get my

read text file byte by byte

2009-12-11 Thread daved170
Hello everybody, I need to read a text file byte after byte. Eache byte is sent to a function that scramble it and I need to write the result to binary file. I've got some questions - 1) How do I read the file byte by byte 2) Should I use streams? If so and I get my entire scrambled text in stream