[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-date: Sat Jan 8 16:49:59 2005 -->
- <!--x-from-r13: wybqra ng gbhtuthl.arg (Xnl Zbqra) -->
- <!--x-message-id: [email protected] -->
- <!--x-subject: [ale] Python - read in text minus "\n" -->
- <li><em>date</em>: Sat Jan 8 16:49:59 2005</li>
- <li><em>from</em>: jloden at toughguy.net (Jay Loden)</li>
- <li><em>subject</em>: [ale] Python - read in text minus "\n"</li>
def serv_list():
grep_tsk = os.popen("grep -l \"start|stop\" " + init_dir + "*")
files = grep_tsk.read().splitlines()
grp_tsk.close()
return files
splitlines([keepends]):
Return a list of the lines in the string, breaking at line boundaries. Line
breaks are not included in the resulting list unless keepends is given and
true.
Thanks for the help though!
-Jay
On Saturday 08 January 2005 3:10, Ben Scherrey wrote:
> Since the grep result is providing the newline then that's the correct
> behaviour (to give you the /n char in your input). But the simplest way
> to get rid of it is to cut it off.
>
> input = x.readline()
> input = input[-1] // or input[-2] for a cr/lf input like from Windows
>
> That do it or did I missunderstand your question?
>
> Ben Scherrey
-------------------------------------------------------
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00284.html">[ale] Python - read in text minus "\n"</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00286.html">[ale] Python - read in text minus "\n"</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00287.html">[ale] Python - read in text minus "\n"</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00288.html">[ale] Bellsouth DSL</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00285"><strong>Date</strong></a></li>
<li><a href="threads.html#00285"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>