[Tutor] [OT] Secure coding guidelines

2009-10-10 Thread Didar Hossain
Hi, This is a little off-topic, but, I though I might put this question in. Since I am learning Python, I was wondering if there are any good references on secure coding practices. Books, guides or even any howtos would suffice. Security seems to be almost always an after-thought rather than bei

Re: [Tutor] If you don't close file when writing, do bytes stay in memory?

2009-10-10 Thread Dave Angel
xbmuncher wrote: Which piece of code will conserve more memory? I think that code #2 will because I close the file more often, thus freeing more memory by closing it. Am I right in this thinking... or does it not save me any more bytes in memory by closing the file often? Sure I realize that in

Re: [Tutor] If you don't close file when writing, do bytes stay in memory?

2009-10-10 Thread Xbox Muncher
What does flush do technically? "Flush the internal buffer, like stdio‘s fflush(). This may be a no-op on some file-like objects." The reason I thought that closing the file after I've written about 500MB file data to it, was smart -> was because I thought that python stores that data in memory or

Re: [Tutor] If you don't close file when writing, do bytes stay in memory?

2009-10-10 Thread Xbox Muncher
Oh yea, it's python 2.6. On Sat, Oct 10, 2009 at 10:32 AM, Xbox Muncher wrote: > What does flush do technically? > "Flush the internal buffer, like stdio‘s fflush(). This may be a no-op on > some file-like objects." > > The reason I thought that closing the file after I've written about 500MB > f

Re: [Tutor] If you don't close file when writing, do bytes stay in memory?

2009-10-10 Thread Kent Johnson
2009/10/10 Xbox Muncher : > What does flush do technically? > "Flush the internal buffer, like stdio‘s fflush(). This may be a no-op on > some file-like objects." > > The reason I thought that closing the file after I've written about 500MB > file data to it, was smart -> was because I thought th

Re: [Tutor] for loop issue

2009-10-10 Thread Rich Lovely
2009/10/9 Oxymoron : > On Fri, Oct 9, 2009 at 11:02 PM, Kent Johnson wrote: >> On Fri, Oct 9, 2009 at 3:54 AM, Stefan Lesicnik wrote: >> >> You can easily keep track of the previous item by assigning it to a >> variable. For example this shows just the increasing elements of a >> sequence: >> >>

Re: [Tutor] If you don't close file when writing, do bytes stay in memory?

2009-10-10 Thread Dave Angel
Kent Johnson wrote: 2009/10/10 Xbox Muncher : What does flush do technically? "Flush the internal buffer, like stdio‘s fflush(). This may be a no-op on some file-like objects." The reason I thought that closing the file after I've written about 500MB file data to it, was smart -> was becau

Re: [Tutor] for loop issue

2009-10-10 Thread Oxymoron
On Sun, Oct 11, 2009 at 4:07 AM, Rich Lovely wrote: > for i, v in enumerate(x[:-1]):  #omitting last value in list to avoid > IndexError >   print v, x[i+1] Thanks for the tip on enumerate, escaped me. Much like Kent's simply using a temporary var escaped me despite having done similar things of

Re: [Tutor] [OT] Secure coding guidelines

2009-10-10 Thread Wayne
On Sat, Oct 10, 2009 at 4:31 AM, Didar Hossain wrote: > Since I am learning Python, I was wondering if there are any good > references on secure > coding practices. Books, guides or even any howtos would suffice. > I'm not sure of any references, but I know of a few things. First, for versions <

Re: [Tutor] [OT] Secure coding guidelines

2009-10-10 Thread Alan Gauld
"Wayne" wrote Data validation is also a good thing: I agree with this bit but... def mysum(n1, n2): try: n1 = int(n1) n2 = int(n2) except ValueError: print "Error! Cannot convert values to int!" return n1+n2 Or do something similar. In a dynamic language

Re: [Tutor] [OT] Secure coding guidelines

2009-10-10 Thread Kent Johnson
On Sat, Oct 10, 2009 at 5:31 AM, Didar Hossain wrote: > Hi, > > This is a little off-topic, but, I though I might put this question in. > > Since I am learning Python, I was wondering if there are any good > references on secure > coding practices. Books, guides or even any howtos would suffice.

Re: [Tutor] Python 3 and tkinter Radiobuttons

2009-10-10 Thread bob smith
Thanks for the reply. Unfortunately, even when I include a variable, all of the buttons start out selected. I noticed that this is the case when I create a StringVar (rather than an IntVar, where the buttons start out correctly unselected). So, here's another simple example wh

Re: [Tutor] Python 3 and tkinter Radiobuttons

2009-10-10 Thread Alan Gauld
"bob smith" wrote So, here's another simple example where all of the radio buttons start out incorrectly selected: v = StringVar() Radiobutton(root, text = "Test RadioButton 1", variable=v, value="1").grid(row = 0, column = 0, sticky = W) Radiobutton(root, text = "Test RadioButton 2