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

2009-10-09 Thread Oxymoron
(Did not do a reply-all earlier) On Sat, Oct 10, 2009 at 3:20 PM, 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 a

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

2009-10-09 Thread xbmuncher
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 my example it doesn

Re: [Tutor] Finding and Inserting missing dates in a date range.

2009-10-09 Thread Glen Zangirolami
Thats for all the responses. I'm going to use Kents method. I'll let you know what I work out. Rudiger - I did think about that. Luckily I am generating the list with a start datetime and end datetime so if those don't exist in either end if the list I can insert them after I check the dates betwee

Re: [Tutor] Finding and Inserting missing dates in a date range.

2009-10-09 Thread Rüdiger Wolf
Ah! but are we sure that the max and min dates are actually in the list? If there are 'missing dates' it might just be possible that it is the max or min date that is missing. On Fri, 09 Oct 2009 16:43 -0400, "Kent Johnson" wrote: > On Fri, Oct 9, 2009 at 3:16 PM, Glen Zangirolami > wrote: > > I

Re: [Tutor] Finding and Inserting missing dates in a date range.

2009-10-09 Thread Kent Johnson
On Fri, Oct 9, 2009 at 3:16 PM, Glen Zangirolami wrote: > If i have a list of dates: > date_list = > ['2008-12-29','2008-12-31','2008-01-01','2008-01-02','2008-01-03','2008-01-05'] > How do I find the missing dates in the range of dates and insert them into > the list so I get? > date_list = > ['2

Re: [Tutor] Finding and Inserting missing dates in a date range.

2009-10-09 Thread Tim Golden
Glen Zangirolami wrote: If i have a list of dates:date_list = ['2008-12-29','2008-12-31','2008-01-01','2008-01-02','2008-01-03','2008-01-05'] How do I find the missing dates in the range of dates and insert them into the list so I get? date_list = ['2008-12-29','2008-12-30','2008-12-31','2008-01

Re: [Tutor] Finding and Inserting missing dates in a date range.

2009-10-09 Thread Wayne
On Fri, Oct 9, 2009 at 2:16 PM, Glen Zangirolami wrote: > If i have a list of dates:date_list = > ['2008-12-29','2008-12-31','2008-01-01','2008-01-02','2008-01-03','2008-01-05'] > > How do I find the missing dates in the range of dates and insert them into > the list so I get? > date_list = > ['20

[Tutor] Finding and Inserting missing dates in a date range.

2009-10-09 Thread Glen Zangirolami
If i have a list of dates:date_list = ['2008-12-29','2008-12-31','2008-01-01','2008-01-02','2008-01-03','2008-01-05'] How do I find the missing dates in the range of dates and insert them into the list so I get? date_list = ['2008-12-29','2008-12-30','2008-12-31','2008-01-01','2008-01-02','2008-01

Re: [Tutor] Troubles with lists and control flow

2009-10-09 Thread Eduardo Vieira
On Thu, Oct 8, 2009 at 3:36 PM, Luke Paireepinart wrote: > Oops, accidentally replied off-list. > > -- Forwarded message -- > From: Luke Paireepinart > Date: Thu, Oct 8, 2009 at 3:36 PM > Subject: Re: [Tutor] Troubles with lists and control flow > To: Eduardo Vieira > > > > > On

Re: [Tutor] for loop issue

2009-10-09 Thread 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: > > In [22]: items = [0, 1, 3, 2,

Re: [Tutor] for loop issue

2009-10-09 Thread Kent Johnson
On Fri, Oct 9, 2009 at 3:54 AM, Stefan Lesicnik wrote: > Hi, > > This feels like a strange issue, so i hope I formulate this so its > understandable. > > I have some objects. Each object has associated values. I am looping > through these objects, working with a value and printing out the > value.

Re: [Tutor] list comprehensions

2009-10-09 Thread Kent Johnson
On Fri, Oct 9, 2009 at 1:21 AM, wesley chun wrote: > [generator expressions] are > "lazy" because you iterate over the values one at a time instead of > creating the entire list. they are slightly slower but save memory. I don't think you can make a blanket statement comparing speed of list comp

Re: [Tutor] for loop issue

2009-10-09 Thread Oxymoron
On Fri, Oct 9, 2009 at 9:35 PM, Oxymoron wrote: > Thus, you can muck around with x[i] (current item), and x[i+1] (next > item), and decide how you want to proceed with the loop. Note the use > of len(x) - 1 rather than just len(x) to easily prevent an IndexError > or extra special case logic. "ea

Re: [Tutor] for loop issue

2009-10-09 Thread Oxymoron
Hello, On Fri, Oct 9, 2009 at 6:54 PM, Stefan Lesicnik wrote: > The issue in this case is that i need to check if the one value > superseeds the other, and in that case, not print it out. I think the > problem is that when you are in the loop, you dont know about the > other object that you haven

[Tutor] for loop issue

2009-10-09 Thread Adam Bark
2009/10/9 Stefan Lesicnik Hi, > > This feels like a strange issue, so i hope I formulate this so its > understandable. > > I have some objects. Each object has associated values. I am looping > through these objects, working with a value and printing out the > value. > The issue in this case is t

[Tutor] for loop issue

2009-10-09 Thread Stefan Lesicnik
Hi, This feels like a strange issue, so i hope I formulate this so its understandable. I have some objects. Each object has associated values. I am looping through these objects, working with a value and printing out the value. The issue in this case is that i need to check if the one value super