Best way to delimit a list?
castironpi at gmail.com
castironpi at gmail.com
Wed May 14 07:59:15 EDT 2008
On May 13, 11:25 pm, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
> On Tue, 13 May 2008 04:14:16 -0700 (PDT), dannywebs... at googlemail.com
> declaimed the following in comp.lang.python:
>
> > So f is a list, rather than a file object, of which os.open would have
> > returned (my initial typo redirected the missive of this post, sorry!)
>
> Other than the facet that os.open() is low-level C file object and
> not a Python file object...
>
> What you have returned is a list of lines... Hmmm, if os.popen()
> supports .readlines() it might even support direct iteration
>
> for ln in os.popen():
> do something with the line
>
> Now the matter comes down to what each line looks like... It is NOT
> a "list" in Python terms, no matter what delimiters it has (and one of
> your examples doesn't even seem to be consistant -- [' .... ]' is not
> the same as [' .... '] )
>
> For space separated hostnames....
>
> for ln in os.popen(...): #assuming it works without a preread
> for host in ln.split():
> do something with host...
> --
> Wulfraed Dennis Lee Bieber KD6MOG
> wlfr... at ix.netcom.com wulfr... at bestiaria.com
> HTTP://wlfraed.home.netcom.com/
> (Bestiaria Support Staff: web-a... at bestiaria.com)
> HTTP://www.bestiaria.com/
Compositions can't have names in the singular case.
More information about the Python-list
mailing list