[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [PATCH 1/2] Store NTP servers in self.data and set them up also on the installed system



On Fri, 2012-06-08 at 09:11 -0700, Brian C. Lane wrote:
> On Fri, Jun 08, 2012 at 11:02:23AM +0200, Vratislav Podzimek wrote:
> > On Thu, 2012-06-07 at 09:52 -0700, Brian C. Lane wrote:
> > > On Thu, Jun 07, 2012 at 03:15:05PM +0200, Vratislav Podzimek wrote:
> > > > +    @property
> > > > +    def servers(self):
> > > > +        ret = list()
> > > > +
> > > > +        itr = self._serversStore.get_iter_first()
> > > > +        while itr:
> > > > +            row = self._serversStore[itr]
> > > > +            if row[2]:
> > > > +                #server checked
> > > > +                ret.append(row[0])
> > > > +
> > > > +            itr = self._serversStore.iter_next()
> > > > +
> > > > +        return ret
> > > 
> > > Can you use for instead? I see that serverStore is a GtkListStore but
> > > hopefully it can be iterated over in a pythonic way:
> > > 
> > > for itr in self._serversStore:
> > >     etc.
> > > 
> > Didn't know about this way, thanks! It should be
> > 
> > for row in self._serversStore:
> >     etc.
> > 
> > because it is iterating over rows, but it works. Great!
> > 
> > However, I'd like to push this as it is and write a new patch changing
> > all GtkListStore iterations using while to use for.
> 
> That's fine with me. While you're at it I also noticed a with open loop
> in ntp.py that could be cleaned up a little. You can now do this to read
> a file:
> 
> with open(filename) as f:
>     for line in f:
>        etc.
> 
> which acts just like using f.readline()
Good to know, thanks! I will add it to the "while-to-for patch" before
pushing.

-- 
Vratislav Podzimek <vpodzime redhat com>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]