Re: Best way to delimit a list?

2008-05-13 Thread dannywebster
On May 13, 11:28 am, [EMAIL PROTECTED] wrote: > Hi - I have a list returned from popen/readlines, and am wondering how > to go about iterating over each item which was returned (rather than > currently having the whole lot returned). > > so far: > > >>> f=os.open("./get_hostnames").readlines > > re

Best way to delimit a list?

2008-05-13 Thread dannywebster
Hi - I have a list returned from popen/readlines, and am wondering how to go about iterating over each item which was returned (rather than currently having the whole lot returned). so far: >>> f=os.open("./get_hostnames").readlines returns ['host1 host2 host3 ... hostN\n]' i'd like to be in a

Re: Best way to delimit a list?

2008-05-13 Thread dannywebster
On May 13, 11:51 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > You meant readlines(), I presume. A file acts as its own iterator: > > f=os.open("./get_hostnames") > try: >for line in f: > # do something with line > finally: >f.close() > > -- > Gabriel Genellina Hi - thank you

Grabbing previous iteration in a dict

2008-05-09 Thread dannywebster
Hello all, I have a dictionary of which i'm itervalues'ing through, and i'll be performing some logic on a particular iteration when a condition is met with trusty .startswith('foo'). I need to grab the previous iteration if this condition is met. I can do something with an extra var to hold eve

Re: Grabbing previous iteration in a dict

2008-05-09 Thread dannywebster
On May 9, 10:48 am, Paul Rubin wrote: > [EMAIL PROTECTED] writes: > > I have a dictionary of which i'm itervalues'ing through, and i'll be > > performing some logic on a particular iteration when a condition is > > met with trusty .startswith('foo'). I need to grab the p

Re: Grabbing previous iteration in a dict

2008-05-09 Thread dannywebster
On May 9, 4:09 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > On May 9, 10:10 am, [EMAIL PROTECTED] wrote: > > > Hello all, > > > I have a dictionary of which i'm itervalues'ing through, and i'll be > > performing some logic on a particular iteration when a condition is > > met with trusty .startswit