Re: [Tutor] how to manage an encrypted file?

2009-06-22 Thread Daniele
> From: "Alan Gauld" > To: tu...@python.org > Date: Mon, 22 Jun 2009 14:15:55 +0100 > Subject: Re: [Tutor] how to manage an encrypted file? >> >> there must be a Security Now episode that explains the thing pretty >> well (could be this one http://www.grc.com/sn/sn-011.htm). > > Eek! I tried to re

Re: [Tutor] filtering NaN values

2009-06-22 Thread John Fouhy
2009/6/23 Alan Gauld : > Interesting! How is a NaN stored in Python? > ie. How do you get to the point of having one in the first place? Well, you can do this: >>> float('nan') nan (try float('inf') too) -- John. ___ Tutor maillist - Tutor@python.o

Re: [Tutor] filtering NaN values

2009-06-22 Thread Alan Gauld
"Kent Johnson" wrote I have a list with some values being NaN (after division-by-zero). How can I check and remove all the NaN values? In Python 2.6 you can use math.isnan() to check for NaN, so you can filter your list by newList = [ x for x in oldList if not math.isnan(x) ] Interesting!

Re: [Tutor] Writing a csv from a dictionary

2009-06-22 Thread Mark Tolonen
"Eduardo Vieira" wrote in message news:9356b9f30906221404o7a7c5e5dt3d59e7b6d40ac...@mail.gmail.com... Hello, I have a dictionary similar to this: dyc = { 'a50' : ['textfield', 50, 40], 'k77' : ['othertext', 60, 10] } I was trying to write a csv with the csv module, by doing this: import csv m

Re: [Tutor] extracting lines in large file

2009-06-22 Thread Vince Spicer
are there any extra spaces of characters " intrinsic" !== "intrinsic" On Monday 22 June 2009 8:14:00 pm Bryan Fodness wrote: > tried both again, they both return the same 9 lines, when i expect > 492. it dies on a blank line, but the if i_line takes care of the > previous ones. > > On Mon, Jun 2

Re: [Tutor] extracting lines in large file

2009-06-22 Thread Bryan Fodness
tried both again, they both return the same 9 lines, when i expect 492. it dies on a blank line, but the if i_line takes care of the previous ones. On Mon, Jun 22, 2009 at 4:21 PM, vince spicer wrote: > 14mb file shouldn't be an issue, unless you very little ram, is there any > errors being outpu

Re: [Tutor] variable length precision

2009-06-22 Thread Kent Johnson
On Mon, Jun 22, 2009 at 7:25 PM, Wayne wrote: > With string formatting I know you can easily specify precision a la > 'file%.2d.jpg' % 1 which would give me 'file01.jpg' but then I discovered > you can indeed chain together formatting (or use variables in place of > string constants... of course s

Re: [Tutor] filtering NaN values

2009-06-22 Thread Kent Johnson
On Mon, Jun 22, 2009 at 4:15 PM, Elisha Rosensweig wrote: > Hi, > > I have a list with some values being NaN (after division-by-zero). How can I > check and remove all the NaN values? In Python 2.6 you can use math.isnan() to check for NaN, so you can filter your list by newList = [ x for x in old

[Tutor] variable length precision

2009-06-22 Thread Wayne
Well, I was going to ask the question, but some experimentation has led me to the answer which I will share. Mainly because I'm sure someone out there may come across the need. I'm writing a function that will generate me a filename such as "file0001.jpg" but I want to be able to specify the min

Re: [Tutor] extracting lines in large file

2009-06-22 Thread Alan Gauld
"Bryan Fodness" wrote I am trying to output all the lines that start with a specific word. It is a large output file (~14 Mb), but nothing that I thought would be a problem. Shouldn't be, you are processing one line at a time! for line in open('output.new'): i_line = line.split() if

Re: [Tutor] filtering NaN values

2009-06-22 Thread Alan Gauld
"Elisha Rosensweig" wrote I have a list with some values being NaN (after division-by-zero). How can I check and remove all the NaN values? NaN is, so far as I know, a JavaScript only feature. The equivalent thing in Python would be to avoid having those 'values' in your list in the first p

[Tutor] Writing a csv from a dictionary

2009-06-22 Thread Eduardo Vieira
Hello, I have a dictionary similar to this: dyc = { 'a50' : ['textfield', 50, 40], 'k77' : ['othertext', 60, 10] } I was trying to write a csv with the csv module, by doing this: import csv myfile = open('c:/myscripts/csv-test.csv', 'wb') mywriter = csv.writer(myfile, dialect='excel') for item in

Re: [Tutor] extracting lines in large file

2009-06-22 Thread vince spicer
14mb file shouldn't be an issue, unless you very little ram, is there any errors being outputted? a cleaner way for reading the file: for line in open("output.new"): if line.startswith("intrinsic"): print line On Mon, Jun 22, 2009 at 2:16 PM, Bryan Fodness wrote: > I am trying to o

[Tutor] extracting lines in large file

2009-06-22 Thread Bryan Fodness
I am trying to output all the lines that start with a specific word. It is a large output file (~14 Mb), but nothing that I thought would be a problem. for line in open('output.new'): i_line = line.split() if i_line: if i_line[0] == "intrinsic": print i_line It does no

[Tutor] filtering NaN values

2009-06-22 Thread Elisha Rosensweig
Hi, I have a list with some values being NaN (after division-by-zero). How can I check and remove all the NaN values? Thanks Elisha ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to manage an encrypted file?

2009-06-22 Thread Eike Welk
The method that Daniele describes is called encryption with a "One Time Pad". A somewhat readable description is in Wikipedia: http://en.wikipedia.org/wiki/One_time_pad This encryption method is a theoretically perfectly secure, but there are big organizational problems connected to its use. It

Re: [Tutor] how to manage an encrypted file?

2009-06-22 Thread Robert Lummis
Very good suggestion! Thanks! I knew about TrueCrypt before (it's really excellent) but I didn't think of it for this purpose because it didn't show up when I did a Synaptic search. I'll see if I can get it installed on ubuntu and used with Python. Actually, the URL you give doesn't work (at least

Re: [Tutor] how to manage an encrypted file?

2009-06-22 Thread Alan Gauld
there must be a Security Now episode that explains the thing pretty well (could be this one http://www.grc.com/sn/sn-011.htm). Eek! I tried to read that but it was so garbled and basically illiterate that I gave up! It's the nearest thing I've seen to plain text encryption! Sample: """ We don't,

Re: [Tutor] how to manage an encrypted file?

2009-06-22 Thread Daniele
> From: Wayne > If you want the most basic encryption you could simply XOR the file. It's > fairly easy to break, though, because the same character patterns will be > present as with your original file. Actually if you do it properly this kind of encryption is unbreakable, but you'd have to: