(Python Newb) Writing to file what is printed?
Question: Thanks to the kindness on this website i've installed
2.7/setuptools/feedparser all without issue.. I've figured out feedparser and
it works without issue.

I've been reading tutorials on how to write to file (text) via python, i've
had moderate success doing this with text.. However when I try to write a list
of data it goes all screwy on me and does nothing at all.

ORIGINAL:

    
    
    import feedparser
    
    result = feedparser.parse('https://gdata.youtube.com/feeds/api/videos/Ej4_G-E1cAM/comments')
    for entry in result.entries:
    print entry.author
    

MY ATTEMPT:

    
    
    import feedparser
    
    result = feedparser.parse('https://gdata.youtube.com/feeds/api/videos/Ej4_G-E1cAM/comments')
    for entry in result.entries:
    with open("write.txt", "w") as text_file:
    text_file.write entry.author
    

I'm attempting to harvest comments for an upcoming giveaway on my YouTube
channel.. If anyone is wondering what i'm using this seemingly useless data
for.

Best Regards, -Mitch Powell


Answer: 
    import feedparser
    f = open('filename','w')
    result = feedparser.parse('https://gdata.youtube.com/feeds/api/videos/Ej4_G-E1cAM/comments')
    for entry in result.entries:
        f.write(entry.author)
    

