[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Sat Jan 8 17:01:42 2005 -->
- <!--x-from-r13: uoof ng pbzpnfg.arg (Xrss Vhoof) -->
- <!--x-message-id: 1105221472.4540.33.camel@juanita -->
- <!--x-reference: [email protected] -->
- <!--x-reference: 41E03E4A.8040105@proteus-tech.com --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] Python - read in text minus "\n" -->
- <li><em>date</em>: Sat Jan 8 17:01:42 2005</li>
- <li><em>from</em>: hbbs at comcast.net (Jeff Hubbs)</li>
- <li><em>in-reply-to</em>: <<a href="msg00284.html">[email protected]</a>></li>
- <li><em>references</em>: <<a href="msg00282.html">[email protected]</a>> <<a href="msg00284.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] Python - read in text minus "\n"</li>
Jeff
On Sat, 2005-01-08 at 15:10, Benjamin 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
>
> Jay Loden wrote:
>
> >I have a question for any Python programmers/hackers out there.
> >
> >I am reading (with popen() ) the return from a grep search. However, using
> >read() or readlines() also reads in "\n" after every result. Anyone know
> >how I can read it in without the newlines?
> >
> >I could of course read through the list and remove the last two characters of
> >every item, but before i do that I wanted to make sure there isn't a function
> >that reads without including \n, \t, \r and such. Alternatively, maybe
> >someone can suggest a regex to parse it out (I don't know regular expressions
> >yet).
> >
> >Thanks for any input!
> >-Jay
> >_______________________________________________
> >Ale mailing list
> >Ale at ale.org
> ><a rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale">http://www.ale.org/mailman/listinfo/ale</a>
> >
> >
> >
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> <a rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale">http://www.ale.org/mailman/listinfo/ale</a>
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00287" href="msg00287.html">[ale] Python - read in text minus "\n"</a></strong>
<ul><li><em>From:</em> jloden at toughguy.net (Jay Loden)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00282" href="msg00282.html">[ale] Python - read in text minus "\n"</a></strong>
<ul><li><em>From:</em> jloden at toughguy.net (Jay Loden)</li></ul></li>
<li><strong><a name="00284" href="msg00284.html">[ale] Python - read in text minus "\n"</a></strong>
<ul><li><em>From:</em> scherrey at proteus-tech.com (Benjamin Scherrey)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00285.html">[ale] Python - read in text minus "\n"</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00287.html">[ale] Python - read in text minus "\n"</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00284.html">[ale] Python - read in text minus "\n"</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00287.html">[ale] Python - read in text minus "\n"</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00286"><strong>Date</strong></a></li>
<li><a href="threads.html#00286"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>