Re: loop through each line in a text file

2010-02-26 Thread OdarR
On 26 fév, 22:08, qtrimble wrote: > I'm a python newbie but I do have some basic scripting experience.  I > need to take the line starting with "wer" and extract the year and day > of year from that string.  I want to be able to add the year and day > of year from the last line having "wer*" to th

Re: loop through each line in a text file

2010-02-26 Thread Alf P. Steinbach
* qtrimble: I'm a python newbie but I do have some basic scripting experience. I need to take the line starting with "wer" and extract the year and day of year from that string. I want to be able to add the year and day of year from the last line having "wer*" to the lines occurring in between

loop through each line in a text file

2010-02-26 Thread qtrimble
I'm a python newbie but I do have some basic scripting experience. I need to take the line starting with "wer" and extract the year and day of year from that string. I want to be able to add the year and day of year from the last line having "wer*" to the lines occurring in between "wer*" lines.

Re: How to efficiently extract information from structured text file

2010-02-18 Thread Paul McGuire
On Feb 17, 7:38 pm, Steven D'Aprano wrote: > On Wed, 17 Feb 2010 17:13:23 -0800, Jonathan Gardner wrote: > > And once you realize that every program is really a compiler, then you > > have truly mastered the Zen of Programming in Any Programming Language > > That Will Ever Exist. > > In the same w

Re: How to efficiently extract information from structured text file

2010-02-17 Thread Steven D'Aprano
On Wed, 17 Feb 2010 17:13:23 -0800, Jonathan Gardner wrote: > And once you realize that every program is really a compiler, then you > have truly mastered the Zen of Programming in Any Programming Language > That Will Ever Exist. In the same way that every tool is really a screwdriver. -- Stev

Re: How to efficiently extract information from structured text file

2010-02-17 Thread Jonathan Gardner
On Feb 16, 3:48 pm, Imaginationworks wrote: > Hi, > > I am trying to read object information from a text file (approx. > 30,000 lines) with the following format, each line corresponds to a > line in the text file.  Currently, the whole file was read into a > string list using

Re: How to efficiently extract information from structured text file

2010-02-17 Thread Imaginationworks
On Feb 17, 1:40 pm, Paul McGuire wrote: > On Feb 16, 5:48 pm, Imaginationworks wrote: > > > Hi, > > > I am trying to read object information from a text file (approx. > > 30,000 lines) with the following format, each line corresponds to a > > line in the text fil

Re: How to efficiently extract information from structured text file

2010-02-17 Thread Paul McGuire
On Feb 16, 5:48 pm, Imaginationworks wrote: > Hi, > > I am trying to read object information from a text file (approx. > 30,000 lines) with the following format, each line corresponds to a > line in the text file.  Currently, the whole file was read into a > string list using

Re: How to efficiently extract information from structured text file

2010-02-17 Thread Imaginationworks
On Feb 16, 7:14 pm, Gary Herron wrote: > Imaginationworks wrote: > > Hi, > > > I am trying to read object information from a text file (approx. > > 30,000 lines) with the following format, each line corresponds to a > > line in the text file.  Currently, the whole f

Re: How to efficiently extract information from structured text file

2010-02-16 Thread Gary Herron
Imaginationworks wrote: Hi, I am trying to read object information from a text file (approx. 30,000 lines) with the following format, each line corresponds to a line in the text file. Currently, the whole file was read into a string list using readlines(), then use for loop to search the

Re: How to efficiently extract information from structured text file

2010-02-16 Thread Rhodri James
On Tue, 16 Feb 2010 23:48:17 -, Imaginationworks wrote: Hi, I am trying to read object information from a text file (approx. 30,000 lines) with the following format, each line corresponds to a line in the text file. Currently, the whole file was read into a string list using readlines

How to efficiently extract information from structured text file

2010-02-16 Thread Imaginationworks
Hi, I am trying to read object information from a text file (approx. 30,000 lines) with the following format, each line corresponds to a line in the text file. Currently, the whole file was read into a string list using readlines(), then use for loop to search the "= {" and "};&qu

Re: Updating an OptionMenu every time the text file it reads from is updated (Tkinter)

2010-01-19 Thread Dr. Benjamin David Clarke
On Jan 19, 7:00 am, Peter Otten <__pete...@web.de> wrote: > Dr. Benjamin David Clarke wrote: > > > I currently have a program that reads in values for an OptionMenu from > > a text file. I also have an option to add a line to that text file > > which corresponds to a

Re: Updating an OptionMenu every time the text file it reads from is updated (Tkinter)

2010-01-19 Thread Peter Otten
Dr. Benjamin David Clarke wrote: > I currently have a program that reads in values for an OptionMenu from > a text file. I also have an option to add a line to that text file > which corresponds to a new value for that OptionMenu. How can I make > that OptionMenu update its values b

Re: Updating an OptionMenu every time the text file it reads from is updated (Tkinter)

2010-01-19 Thread Alf P. Steinbach
* Dr. Benjamin David Clarke: I currently have a program that reads in values for an OptionMenu from a text file. I also have an option to add a line to that text file which corresponds to a new value for that OptionMenu. How can I make that OptionMenu update its values based on that text file

Updating an OptionMenu every time the text file it reads from is updated (Tkinter)

2010-01-18 Thread Dr. Benjamin David Clarke
I currently have a program that reads in values for an OptionMenu from a text file. I also have an option to add a line to that text file which corresponds to a new value for that OptionMenu. How can I make that OptionMenu update its values based on that text file without restarting the program

Re: lightweight encryption of text file

2010-01-18 Thread Aahz
he laptop with the file I seriously doubt anybody who >finds it will go through each and every file and try to find what's in >it, even though they look like data files and there is no hint what so >ever that any one of them contains encrypted info. If they see a text >file, well, tha

Re: lightweight encryption of text file

2010-01-12 Thread Ethan Furman
Anthra Norell wrote: > I consider the encryption unbreakable [...] (from previous thread) I am not a cryptographer. (from this thread) Then you shouldn't be making claims about your encryption algorithms. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: lightweight encryption of text file

2010-01-12 Thread Anthra Norell
Robert Kern wrote: On 2010-01-12 05:59 AM, Anthra Norell wrote: Robert Kern wrote: On 2010-01-11 14:09 PM, Anthra Norell wrote: Robert Kern wrote: On 2010-01-09 03:52 AM, Anthra Norell wrote: Upon which another critic conjured up the horror vision of gigahertzes hacking my pathetic little

Re: lightweight encryption of text file

2010-01-12 Thread Steve Holden
Robert Kern wrote: > On 2010-01-12 05:59 AM, Anthra Norell wrote: [ping, pong, ping, pong] > If the OP uses a real encryption algorithm, he can rely on the fact that > he can use the algorithm for large files or for plaintexts that a > malicious agent might choose even if he did not communicate (or

Re: lightweight encryption of text file

2010-01-12 Thread Robert Kern
On 2010-01-12 05:59 AM, Anthra Norell wrote: Robert Kern wrote: On 2010-01-11 14:09 PM, Anthra Norell wrote: Robert Kern wrote: On 2010-01-09 03:52 AM, Anthra Norell wrote: Upon which another critic conjured up the horror vision of gigahertzes hacking my pathetic little effort to pieces as

Re: lightweight encryption of text file

2010-01-12 Thread Anthra Norell
Robert Kern wrote: On 2010-01-11 14:09 PM, Anthra Norell wrote: Robert Kern wrote: On 2010-01-09 03:52 AM, Anthra Norell wrote: "Don't use a random generator for encryption purposes!" warns the manual, of which fact I was reminded in no uncertain terms on this forum a few years ago when I p

Re: lightweight encryption of text file

2010-01-12 Thread John Bokma
Anthra Norell writes: > Why EVER make anything yourself when you can buy it? Do you make your own processors? Your own hard disk drives? Why not? -- John Bokma Read my blog: http://johnbokma.com/ Hire me (Perl/Python): http://castleamber.com/ -- http://mail.python.org/mailman/listinfo/python

Re: lightweight encryption of text file

2010-01-12 Thread Paul Rubin
John Bokma writes: >> Why EVER make anything yourself when you can buy it? > > Do you make your own processors? Your own hard disk drives? > Why not? Well, if you try to make your own processors or hard drives, worst normal outcome is they don't work and you try something else instead. This is mo

Re: lightweight encryption of text file

2010-01-11 Thread John Bokma
Paul Rubin writes: > John Bokma writes: >>> Why EVER make anything yourself when you can buy it? >> >> Do you make your own processors? Your own hard disk drives? >> Why not? > > Well, if you try to make your own processors or hard drives, worst > normal outcome is they don't work and you try so

Re: lightweight encryption of text file

2010-01-11 Thread Robert Kern
On 2010-01-11 14:09 PM, Anthra Norell wrote: Robert Kern wrote: On 2010-01-09 03:52 AM, Anthra Norell wrote: "Don't use a random generator for encryption purposes!" warns the manual, of which fact I was reminded in no uncertain terms on this forum a few years ago when I proposed the following

Re: lightweight encryption of text file

2010-01-11 Thread Paul Rubin
Anthra Norell writes: > Why EVER make anything yourself when you can buy it? http://en.wikipedia.org/wiki/Dunning-Kruger_effect -- http://mail.python.org/mailman/listinfo/python-list

Re: lightweight encryption of text file

2010-01-11 Thread Anthra Norell
Robert Kern wrote: On 2010-01-09 03:52 AM, Anthra Norell wrote: Daniel Fetchinson wrote: > I have a plain text file which I would like to protect in a very > simple minded, yet for my purposes sufficient, way. I'd like to > encrypt/convert it into a binary file in such a way th

Re: lightweight encryption of text file

2010-01-11 Thread Robert Kern
On 2010-01-09 03:52 AM, Anthra Norell wrote: Daniel Fetchinson wrote: > I have a plain text file which I would like to protect in a very > simple minded, yet for my purposes sufficient, way. I'd like to > encrypt/convert it into a binary file in such a way that possession of

Re: lightweight encryption of text file

2010-01-11 Thread Paul Rubin
geremy condra writes: > And having no dependencies frees you from the burden of testing > where your software will be deployed? I don't think so. If you just use the stdlib and are a bit careful about OS dependent features, your code can run pretty much everywhere. More to the point, if (say) yo

Re: lightweight encryption of text file

2010-01-10 Thread Steve Holden
Carl Banks wrote: > On Jan 8, 11:14 am, Daniel Fetchinson > wrote: >> I have a plain text file which I would like to protect in a very >> simple minded, yet for my purposes sufficient, way. I'd like to >> encrypt/convert it into a binary file in such a way that posse

Re: lightweight encryption of text file

2010-01-10 Thread geremy condra
On Sun, Jan 10, 2010 at 3:26 PM, Paul Rubin wrote: > geremy condra writes: >> Not sure why in the world you would homebrew something like this- a >> small dependency isn't that bad, and aes can be pretty simple to use. >> Might as well go for the industrial strength approach. > > In my experience

Re: lightweight encryption of text file

2010-01-10 Thread Carl Banks
On Jan 8, 11:14 am, Daniel Fetchinson wrote: > I have a plain text file which I would like to protect in a very > simple minded, yet for my purposes sufficient, way. I'd like to > encrypt/convert it into a binary file in such a way that possession of > a password allows anyone t

Re: lightweight encryption of text file

2010-01-10 Thread Steve Holden
Paul Rubin wrote: > Steve Holden writes: >>> Right now, even asking for HTTPS support is too much to ask. Heck, >>> even asking for the fake HTTPS support to be identified as such is too >>> much, apparently. >>> >> No, Paul, nobody will complain if you *ask* ... > > Er, that wasn't me... > Oh s

Re: lightweight encryption of text file

2010-01-10 Thread Paul Rubin
Nobody writes: > But, yeah, the OP needs to be aware of the difference (and probably isn't, > yet). So to take that a step further ... > The key passed to arcfour.schedule() shouldn't be re-used > If you need to verify the data, append a hash of the ciphertext ... > If you want to encrypt mul

Re: lightweight encryption of text file

2010-01-10 Thread Paul Rubin
Steve Holden writes: >> Right now, even asking for HTTPS support is too much to ask. Heck, >> even asking for the fake HTTPS support to be identified as such is too >> much, apparently. >> > No, Paul, nobody will complain if you *ask* ... Er, that wasn't me... > A question I've been asking myse

Re: lightweight encryption of text file

2010-01-10 Thread Steve Holden
Nobody wrote: > On Sun, 10 Jan 2010 12:26:05 -0800, Paul Rubin wrote: > >> I'd like it a lot if the Python stdlib could include a serious >> cryptography module. > > And I'd like a truckload of gold ;) > > Right now, even asking for HTTPS support is too much to ask. Heck, > even asking for the f

Re: lightweight encryption of text file

2010-01-10 Thread Nobody
On Sun, 10 Jan 2010 12:26:05 -0800, Paul Rubin wrote: > I'd like it a lot if the Python stdlib could include a serious > cryptography module. And I'd like a truckload of gold ;) Right now, even asking for HTTPS support is too much to ask. Heck, even asking for the fake HTTPS support to be identi

Re: lightweight encryption of text file

2010-01-10 Thread Nobody
On Sun, 10 Jan 2010 08:54:51 -0800, Paul Rubin wrote: > Nobody writes: >> RC4 (aka ArcFour) is quite trivial to implement, and better than inventing >> your own cipher or using a Vignere: ... > > That's a cute implementation, but it has no authentication and doesn't > include any randomness, whi

Re: lightweight encryption of text file

2010-01-10 Thread Paul Rubin
geremy condra writes: > Not sure why in the world you would homebrew something like this- a > small dependency isn't that bad, and aes can be pretty simple to use. > Might as well go for the industrial strength approach. In my experience, 1) small dependencies ARE that bad, since they mean you ha

Re: lightweight encryption of text file

2010-01-10 Thread geremy condra
Not sure why in the world you would homebrew something like this- a small dependency isn't that bad, and aes can be pretty simple to use. Might as well go for the industrial strength approach. Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list

Re: lightweight encryption of text file

2010-01-10 Thread Paul Rubin
Nobody writes: > RC4 (aka ArcFour) is quite trivial to implement, and better than inventing > your own cipher or using a Vignere: ... That's a cute implementation, but it has no authentication and doesn't include any randomness, which means if you use the same key for two inputs, there is a secur

Re: lightweight encryption of text file

2010-01-10 Thread Daniel Fetchinson
>> Thanks, this looks very simple too, but where is the decryption code? >> Wikipedia seems to suggest that encryption and decryption are both the >> same but running crypt on the output of crypt doesn't give back the >> original string. So probably I'm misunderstanding something. > > Yes, the natu

Re: lightweight encryption of text file

2010-01-10 Thread Nobody
On Sun, 10 Jan 2010 15:30:12 +, Steven D'Aprano wrote: >> Thanks, this looks very simple too, but where is the decryption code? >> Wikipedia seems to suggest that encryption and decryption are both the >> same but running crypt on the output of crypt doesn't give back the >> original string. S

Re: lightweight encryption of text file

2010-01-10 Thread Nobody
On Sun, 10 Jan 2010 09:59:31 +0100, Daniel Fetchinson wrote: > Thanks, this looks very simple too, but where is the decryption code? > Wikipedia seems to suggest that encryption and decryption are both the > same but running crypt on the output of crypt doesn't give back the > original string. So

Re: lightweight encryption of text file

2010-01-10 Thread Steven D'Aprano
On Sun, 10 Jan 2010 09:59:31 +0100, Daniel Fetchinson wrote: > Thanks, this looks very simple too, but where is the decryption code? > Wikipedia seems to suggest that encryption and decryption are both the > same but running crypt on the output of crypt doesn't give back the > original string. So

Re: lightweight encryption of text file

2010-01-10 Thread Daniel Fetchinson
>> I have a plain text file which I would like to protect in a very >> simple minded, yet for my purposes sufficient, way. I'd like to >> encrypt/convert it into a binary file in such a way that possession of >> a password allows anyone to convert it back into the or

Re: lightweight encryption of text file

2010-01-10 Thread Nobody
On Fri, 08 Jan 2010 20:14:51 +0100, Daniel Fetchinson wrote: > I have a plain text file which I would like to protect in a very > simple minded, yet for my purposes sufficient, way. I'd like to > encrypt/convert it into a binary file in such a way that possession of > a password

Re: lightweight encryption of text file

2010-01-09 Thread Paul Rubin
Robert Kern writes: > Are you on a 64-bit platform? Unfortunately, array's integer typecodes > are platform-specific, but p3.py requires a 32-bit integer ... Oh yes, thanks, I never did get around to dealing with 64 bit platforms. I also notice that some of the unit test functions use print state

Re: lightweight encryption of text file

2010-01-09 Thread Paul Rubin
Daniel Fetchinson writes: > I have a plain text file which I would like to protect in a very > simple minded, yet for my purposes sufficient, way. For encrypting strings, use this module: http://nightsong.com/phr/crypto/p3.py Obviously this is limited to strings that fit in memory,

Re: lightweight encryption of text file

2010-01-09 Thread Paul Rubin
Daniel Fetchinson writes: >>http://www.nightsong.com/phr/crypto/p3.py > > Thanks a lot, currently I'm having trouble using this code on python > 2.6 but probably some small tweaking will fix it. Yikes, this is the first I've heard of such a problem. I will look into it. Thanks. (Also than

Re: lightweight encryption of text file

2010-01-09 Thread Daniel Fetchinson
>> I have a plain text file which I would like to protect in a very >> simple minded, yet for my purposes sufficient, way. I'd like to >> encrypt/convert it into a binary file in such a way that possession of >> a password allows anyone to convert it back into the or

Re: lightweight encryption of text file

2010-01-09 Thread Arnaud Delobelle
Daniel Fetchinson writes: > I have a plain text file which I would like to protect in a very > simple minded, yet for my purposes sufficient, way. I'd like to > encrypt/convert it into a binary file in such a way that possession of > a password allows anyone to convert it back

Re: lightweight encryption of text file

2010-01-09 Thread Dave Angel
Anthra Norell wrote: Daniel Fetchinson wrote: > I have a plain text file which I would like to protect in a very > simple minded, yet for my purposes sufficient, way. I'd like to > encrypt/convert it into a binary file in such a way that possession of > a password allows any

Re: lightweight encryption of text file

2010-01-09 Thread Daniel Fetchinson
> > I have a plain text file which I would like to protect in a very > > simple minded, yet for my purposes sufficient, way. I'd like to > > encrypt/convert it into a binary file in such a way that possession of > > a password allows anyone to convert it back int

Re: lightweight encryption of text file

2010-01-09 Thread Daniel Fetchinson
On 1/9/10, Steven D'Aprano wrote: > On Fri, 08 Jan 2010 20:14:51 +0100, Daniel Fetchinson wrote: > >> I have a plain text file which I would like to protect in a very simple >> minded, yet for my purposes sufficient, way. I'd like to encrypt/convert >> it int

Re: lightweight encryption of text file

2010-01-09 Thread Daniel Fetchinson
>>>>> I have a plain text file which I would like to protect in a very >>>>> simple minded, yet for my purposes sufficient, way. I'd like to >>>>> encrypt/convert it into a binary file in such a way that possession of >>>>> a

Re: lightweight encryption of text file

2010-01-09 Thread Anthra Norell
Daniel Fetchinson wrote: > I have a plain text file which I would like to protect in a very > simple minded, yet for my purposes sufficient, way. I'd like to > encrypt/convert it into a binary file in such a way that possession of > a password allows anyone to convert it back

Re: lightweight encryption of text file

2010-01-08 Thread Steven D'Aprano
On Fri, 08 Jan 2010 20:14:51 +0100, Daniel Fetchinson wrote: > I have a plain text file which I would like to protect in a very simple > minded, yet for my purposes sufficient, way. I'd like to encrypt/convert > it into a binary file in such a way that possession of a password allo

Re: lightweight encryption of text file

2010-01-08 Thread Chris Colbert
PyCrypto is already pretty easy to use by itself. I dont know why you want a wrapper on top of it. On Fri, Jan 8, 2010 at 11:02 PM, Irmen de Jong wrote: > On 8-1-2010 22:39, Daniel Fetchinson wrote: > >> >>>http://www.nightsong.com/phr/crypto/p3.py >>> >> >> Thanks a lot, currently I'm having

Re: lightweight encryption of text file

2010-01-08 Thread Robert Kern
On 2010-01-08 15:47 PM, Daniel Fetchinson wrote: I have a plain text file which I would like to protect in a very simple minded, yet for my purposes sufficient, way. I'd like to encrypt/convert it into a binary file in such a way that possession of a password allows anyone to convert it

Re: lightweight encryption of text file

2010-01-08 Thread Irmen de Jong
On 8-1-2010 22:39, Daniel Fetchinson wrote: http://www.nightsong.com/phr/crypto/p3.py Thanks a lot, currently I'm having trouble using this code on python 2.6 but probably some small tweaking will fix it. If you keep having issues with this module, maybe you can try this: http://www.fre

Re: lightweight encryption of text file

2010-01-08 Thread Daniel Fetchinson
>>> I have a plain text file which I would like to protect in a very >>> simple minded, yet for my purposes sufficient, way. I'd like to >>> encrypt/convert it into a binary file in such a way that possession of >>> a password allows anyone to convert it b

Re: lightweight encryption of text file

2010-01-08 Thread Daniel Fetchinson
>> I have a plain text file which I would like to protect in a very >> simple minded, yet for my purposes sufficient, way. I'd like to >> encrypt/convert it into a binary file in such a way that possession of >> a password allows anyone to convert it back into the or

Re: lightweight encryption of text file

2010-01-08 Thread Robert Kern
On 2010-01-08 13:14 PM, Daniel Fetchinson wrote: I have a plain text file which I would like to protect in a very simple minded, yet for my purposes sufficient, way. I'd like to encrypt/convert it into a binary file in such a way that possession of a password allows anyone to convert it

lightweight encryption of text file

2010-01-08 Thread Daniel Fetchinson
I have a plain text file which I would like to protect in a very simple minded, yet for my purposes sufficient, way. I'd like to encrypt/convert it into a binary file in such a way that possession of a password allows anyone to convert it back into the original text file while not possessin

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: &g

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
e 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(filename, 'r')  # open in text mode > > f.rea

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 statem

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
wlfr...@ix.netcom.com HTTP://wlfraed.home.netcom.com/ 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. Thanks again All

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&#x

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 ti

Re: read text file byte by byte

2009-12-12 Thread daved170
(sys.argv) > 3: >         key = sys.argv[3] >     else: >         key = None >     process(fin, fout, key) > -- >         Wulfraed         Dennis Lee Bieber               KD6MOG >         wlfr...@ix.netcom.com      HTTP://wlfraed.home.netcom.com/ Thank you all. Dennis I r

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 th

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

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

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 te

Re: reading from a text file

2009-11-30 Thread Tim Golden
inhahe wrote: i don't understand the point of using 'with' but i don't understand what 'with' does at all i've tried to understand it a few times anyway here: import random result = random.choice(open("c:\\test.txt").readlines()) Yep. That'll do the trick. The point of "with" is that, while i

Re: reading from a text file

2009-11-30 Thread inhahe
AM, Tim Golden wrote: > Olof Bjarnason wrote: >> >> 2009/11/27 baboucarr sanneh : >>> >>> hi all >>> >>> i would like to create a python program that would read from a text file >>> and >>> returns one result at random. >>>

Re: reading from a text file

2009-11-30 Thread Tim Golden
Olof Bjarnason wrote: 2009/11/27 baboucarr sanneh : hi all i would like to create a python program that would read from a text file and returns one result at random. e.g in the text file i have these data 1.hello 2.my name 3.is 4.World Your help is highly appreciated..thnx in advance Hi

Re: reading from a text file

2009-11-30 Thread Esmail
baboucarr sanneh wrote: i would like to create a python program that would read from a text file and returns one result at random. #!/usr/bin/env python # assuming the file fits into memory, and you are interested in # random lines from random import randrange f = open('data.txt&#

Re: reading from a text file

2009-11-30 Thread Simon Brunning
2009/11/27 baboucarr sanneh : > hi all > > i would like to create a python program that would read from a text file and > returns one result at random. This might be of use: http://code.activestate.com/recipes/426332/#c2 -- Cheers, Simon B. -- http://mail.python.org/mailman/lis

<    1   2   3   4   5   6   7   8   9   10   >