Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread Martin Walsh
David wrote: > Martin Walsh wrote: > >> Welcome! > > thanks welcome (uh oh, infinite loop warning) > This "podcast_file.write('%s: %s' % (entry.updated, entry.link))" > writes it in one very long string Copy and paste gets me every time. Try this, and note the presence of the newline ('\n'):

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread Alan Gauld
"David" wrote sys.stdout = open("podcast_links.txt", "a") print '%s' % (entry.link) sys.stdout.close() getFeed() This "podcast_file.write('%s: %s' % (entry.updated, entry.link))" writes it in one very long string Use podcastfile.writeline() to write it line by line

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread David
Martin Walsh wrote: Welcome! thanks You should probably try to avoid reassigning sys.stdout. This is usually a bad idea, and can cause odd behavior that is difficult to troubleshoot, especially for a beginner. A reasonable approach is to assign the open file object to a name of your own ch

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread Martin Walsh
Hi David, David wrote: > Hi everyone. > Just learning :) I have one program to parse a podcast feed and put it > into a file. Welcome! > > def getFeed(): > url = raw_input("Please enter the feed: ") > data = feedparser.parse(url) > for entry in data.entries: > sys.stdout =

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread Kent Johnson
On Sun, Dec 21, 2008 at 7:29 PM, David wrote: > This seems to work; > > download = L.readline() > print download > download = download[0:-1] > > What is that last character that is added; > .mp3%0A It is a newline character (line feed). readline() includes the line endings in the returned lines.

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread David
This seems to work; download = L.readline() print download download = download[0:-1] What is that last character that is added; .mp3%0A -- Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com pgp.mit.edu ___ Tutor maillist - Tutor@python.org http

[Tutor] subprocess adds %0A to end of string

2008-12-21 Thread David
Hi everyone. Just learning :) I have one program to parse a podcast feed and put it into a file. #!/usr/bin/python """Get feed date and link details""" import feedparser import sys def getFeed(): url = raw_input("Please enter the feed: ") data = feedparser.parse(url) for entry in d