accessing a text file

geremy condra debatem1 at gmail.com
Mon Sep 6 12:14:41 EDT 2010


On Mon, Sep 6, 2010 at 8:53 AM, Baba <raoulbia at gmail.com> wrote:
> On 6 sep, 16:58, Thomas Jollans <tho... at jollybox.de> wrote:
>> On Monday 06 September 2010, it occurred to Baba to exclaim:
>>
>>
>>
>> > On 6 sep, 00:01, Benjamin Kaplan <benjamin.kap... at case.edu> wrote:
>> > > On Sun, Sep 5, 2010 at 5:47 PM, Baba <raoul... at gmail.com> 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
>> > > > --
>>
>> > > >http://mail.python.org/mailman/listinfo/python-list
>>
>> > > 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.
>>
>> > >http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-...
>>
>> > 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.
>>
>> That is of course perfectly legitimate. It would however have been polite to
>> state that in the question. Show us that you're doing your homework, and not
>> just using the list as a cheap path to having to think less yourself.
>>
>> Phrasing your post as "I would like to compare a ... I found the open()
>> function here: [link]. Is this what I should use of is there any other/better
>> way?" makes a completely different impression.
>>
>> Also, keeping personal comments to one's self is just not how it works. On a
>> list like this especially, answers along the lines of "That's the way to do
>> what you were asking for, but are you sure the question went into the right
>> direction? Have you thought of [...]?" can often be very helpful.
>>
>>
>>
>> > To all other respondants: thank you for your kind instructions and
>> > directions.
>>
>>
>
> Thanks Thomas. Look up some of my questions  this group and read
> through them and come back to tell me if a) i use this forum to learn
> without making any efforts myself

Just a quick point- when you ask someone for help, it's considered
impolite to tell them what to do.

I'd also point out that you gave no indication that you'd worked on
this at all before posting it. In that regard, Thomas's concern seems
completely justified to me.

> or b) i use this forum to get
> started using the expertise of more knowledgeable programmers while at
> the same time particiapting.

Again, Thomas's concern seems justified to me. Things would probably
go more smoothly if you gave a better indication of what you had done
so far on the problem in the future.

> Anyway having this discussion is beside
> the point. Any Expert out there who thinks we beginners are some dumb
> idiots who are too stupid to think for themselves and are lucky to
> have a bunch of geniuses like you to help, get lost or make yourself a
> cup of tea but please give me a break from teaching me lessons...

I don't think all beginners are idiots, or even most of them- but this
isn't the right attitude to be taking. Both Thomas and myself thought
that this was inappropriate enough to mention it, and if two people
spoke up you can bet a lot more were thinking it quietly. My
suggestion would be to moderate your approach and demonstrate what
you've done so far (if only to increase the signal-to-noise ratio as
your problems become more challenging) when posting. I'd also refrain
from telling people to get lost; it doesn't make people happy to help
you, you know?

Geremy Condra



More information about the Python-list mailing list