accessing a text file

Baba raoulbia at
Mon Sep 6 09:55:28 CEST 2010

On 6 sep, 00:01, Benjamin Kaplan <benjamin.kap... at> wrote:
> On Sun, Sep 5, 2010 at 5:47 PM, Baba <raoul... at> wrote:
> > level: beginner
> > how can i access the contents of a text file in Python?
> > i would like to compare a string (word) with the content of a text
> > file (word_list). i want to see if word is in word_list. let's assume
> > the TXT file is stored in the same directory as the PY file.
> > def is_valid_word(word, word_list)
> > thanks
> > Baba
> > --
> >
> Please do us a favor and at least try to figure things out on your
> own, rather than coming here every time you have a question. The very
> first result when you try searching "python read text file" is the
> section in the Python tutorial that explains how to do this.

Hi Benjamin

I did find that page prior to posting the question but i still wanted
to have a second opinion to complement that info so as to make things
easier The first line of my post clearly states that i am a beginner.
It's nice to provide links which can help answer the question but
please be so polite and keep personal comments for yourself.

To all other respondants: thank you for your kind instructions and


More information about the Python-list mailing list