Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > accessing a text file

Reply
Thread Tools

accessing a text file

 
 
geremy condra
Guest
Posts: n/a
 
      09-06-2010
On Mon, Sep 6, 2010 at 8:53 AM, Baba <> wrote:
> On 6 sep, 16:58, Thomas Jollans <tho...@jollybox.de> wrote:
>> On Monday 06 September 2010, it occurred to Baba to exclaim:
>>
>>
>>
>> > On 6 sep, 00:01, Benjamin Kaplan <benjamin.kap...@case.edu> wrote:
>> > > On Sun, Sep 5, 2010 at 5:47 PM, Baba <raoul...@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/inpu...g-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
 
Reply With Quote
 
 
 
 
Baba
Guest
Posts: n/a
 
      09-06-2010
On 6 sep, 18:14, geremy condra <debat...@gmail.com> wrote:
> On Mon, Sep 6, 2010 at 8:53 AM, Baba <raoul...@gmail.com> wrote:
> > On 6 sep, 16:58, Thomas Jollans <tho...@jollybox.de> wrote:
> >> On Monday 06 September 2010, it occurred to Baba to exclaim:

>
> >> > On 6 sep, 00:01, Benjamin Kaplan <benjamin.kap...@case.edu> wrote:
> >> > > On Sun, Sep 5, 2010 at 5:47 PM, Baba <raoul...@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/inpu...g-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


Thanks Jeremy, i will take your advice on board! Noone likes to be
taught lessons i think so it is only normal that i reacted. If i had
received a friendly response from Benjamin (as opposed to "Please do
us a favor and at least try to figure things out on your own") making
me aware of the etiquette that my post should also show that i have
researched my question somehow and if his tone would have been
mannered then we would not be having this discussion now. Ok now i
need to go back to actual Pythoon learning, i'm getting distracted.

Kind regards,
Baba

 
Reply With Quote
 
 
 
 
Baba
Guest
Posts: n/a
 
      09-07-2010
On 7 sep, 02:18, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
> Ben Finney <ben+pyt...@benfinney.id.au> writes:
> > We value respect for people here, and that's what you've been shown
> > consistently. But respect for opinions, or for delicacy about
> > learning, is not welcome here.

>
> Sloppy wording, I apologise. This should say “… is not respect for a
> person”.
>
> > In other words, we treat people as adults by default. I hope you'll
> > continue to participate in that spirit.

>
> This is the main thrust of the message.
>
> --
> *\ * * * *“What if the Hokey Pokey IS what it's all about?” —anonymous |
> * `\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
> _o__) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *|
> Ben Finney


Yes Master
 
Reply With Quote
 
Baba
Guest
Posts: n/a
 
      09-07-2010
On 7 sep, 13:39, Baba <raoul...@gmail.com> wrote:
> On 7 sep, 02:18, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
>
>
>
>
>
> > Ben Finney <ben+pyt...@benfinney.id.au> writes:
> > > We value respect for people here, and that's what you've been shown
> > > consistently. But respect for opinions, or for delicacy about
> > > learning, is not welcome here.

>
> > Sloppy wording, I apologise. This should say “… is not respect for a
> > person”.

>
> > > In other words, we treat people as adults by default. I hope you'll
> > > continue to participate in that spirit.

>
> > This is the main thrust of the message.

>
> > --
> > *\ * * * *“What if the Hokey Pokey IS what it's all about?” —anonymous |
> > * `\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
> > _o__) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *|
> > Ben Finney

>
> Yes Master


Sloppy wording, I apologise. This should say: If you find the question
you're reading too easy then just don't answer. Noone is the owner of
a democratic forum where freedom to ask the question one likes is
paramount (as long of course as it is related to the group)...so let
me repeat that, to say "Please do us a favour and at least try to
figure things out on your own" is in my view inappropriate. To me it
sounds "Do me a favur and get lost". Can you not understand that? I
accept that it might not have been meant that way but see,
misunderstandings happen easily so a more subtle approach is a
wothwhile effort. My point: i always encourage people to get down
from their ivory towers and to connect to the people...yes they will
sometimes be lazy but they are genuine and very respectful (unlike
what you think)...

no offence now ok, it's not all that serious...open your mind, let
lose all that righteousness and let's enjoy life


Baba
 
Reply With Quote
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      09-07-2010
Baba a écrit :
(snip)
> If i had
> received a friendly response from Benjamin (as opposed to "Please do
> us a favor and at least try to figure things out on your own")


According to usenet standards and given your initial question, this is a
_very_ friendly answer.
 
Reply With Quote
 
Grant Edwards
Guest
Posts: n/a
 
      09-07-2010
On 2010-09-07, Baba <> wrote:

> Sloppy wording, I apologise. This should say: If you find the
> question you're reading too easy then just don't answer. Noone is the
> owner of a democratic forum where freedom to ask the question one
> likes is paramount (as long of course as it is related to the
> group)...so let me repeat that, to say "Please do us a favour and at
> least try to figure things out on your own" is in my view
> inappropriate.


You need to read this:

http://www.catb.org/esr/faqs/smart-questions.html

> To me it sounds "Do me a favur and get lost".


No, it means "Do yourself a favor, learn how to do things yourself."

Remember: you're then one asking people to give you something for
free. It's not up to them to conform to your expectations, rather you
need to conform to theirs. Otherwise, they'll just ignore you.

--
Grant Edwards grant.b.edwards Yow! FOOLED you! Absorb
at EGO SHATTERING impulse
gmail.com rays, polyester poltroon!!
 
Reply With Quote
 
Baba
Guest
Posts: n/a
 
      09-07-2010
On 7 sep, 16:50, Grant Edwards <inva...@invalid.invalid> wrote:
> On 2010-09-07, Baba <raoul...@gmail.com> wrote:
>
> > Sloppy wording, I apologise. This should say: If you find the
> > question you're reading too easy then just don't answer. Noone is the
> > owner of a democratic forum where freedom to ask the question one
> > likes is paramount (as long of course as it is related to the
> > group)...so let me repeat that, to say "Please do us a favour and at
> > least try to figure things out on your own" is in my view
> > inappropriate.

>
> You need to read this:
>
> *http://www.catb.org/esr/faqs/smart-questions.html
>
> > To me it sounds "Do me a favur and get lost".

>
> No, it means "Do yourself a favor, learn how to do things yourself."
>
> Remember: you're then one asking people to give you something for
> free. It's not up to them to conform to your expectations, rather you
> need to conform to theirs. *Otherwise, they'll just ignore you.
>
> --
> Grant Edwards * * * * * * * grant.b.edwards * * * *Yow! FOOLED you! *Absorb
> * * * * * * * * * * * * * * * * * at * * * * * * * EGO SHATTERING impulse
> * * * * * * * * * * * * * * * gmail.com * * * * * *rays, polyester poltroon!!


"Please do us a favour" sounds condescending to me at least but maybe
we Europeans are a bit touchy...

However the following Wiki excerpt seems to go in my direction:

"When someone makes a mistake -- whether it's a spelling error or a
spelling flame, a stupid question or an unnecessarily long answer --
be kind about it. If it's a minor error, you may not need to say
anything. Even if you feel strongly about it, think twice before
reacting. Having good manners yourself doesn't give you license to
correct everyone else. If you do decide to inform someone of a
mistake, point it out politely, and preferably by private email rather
than in public. Give people the benefit of the doubt; assume they just
don't know any better. And never be arrogant or self-righteous about
it."

http://en.wikipedia.org/wiki/Netiquette

Baba

 
Reply With Quote
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      09-08-2010
On Wed, 08 Sep 2010 10:07:19 +1000, Ben Finney
<ben+> declaimed the following in
gmane.comp.python.general:

> Baba <> writes:
>
> > However the following Wiki excerpt seems to go in my direction:

>
> No, it doesn't. It advises that people show kindness; as I've been
> arguing, that's exactly what you were shown. You haven't shown how the
> information being imparted could have been fully imparted in a way
> that's kinder, nor that it would be reasonable to do so.
>

Be glad I didn't respond to the OP... I don't know what version of
Python they are using but with ActiveState 2.5.x under WinXP on my
systems, my response would have been on the order of...

"
Did you try the help system? Takes less than 10 minutes with
<aforesaid install> to pop up the Python help file, pick the search tab,
and enter
read a file
in the search box, whereupon the first entry is chapter x.y.z of the
included text /Dive Into Python/.
"
--
Wulfraed Dennis Lee Bieber AF6VN
HTTP://wlfraed.home.netcom.com/

 
Reply With Quote
 
Baba
Guest
Posts: n/a
 
      09-08-2010
On 8 sep, 02:07, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
> Baba <raoul...@gmail.com> writes:
> > However the following Wiki excerpt seems to go in my direction:

>
> No, it doesn't. It advises that people show kindness; as I've been
> arguing, that's exactly what you were shown. You haven't shown how the
> information being imparted could have been fully imparted in a way
> that's kinder, nor that it would be reasonable to do so.
>
> To put it another way: if you feel offended by an utterance, then
> insufficient kindness on the part of the speaker is not the only
> explanation.
>
> --
> *\ * * *“Software patents provide one more means of controlling access |
> * `\ * * *to information. They are the tool of choice for the internet |
> _o__) * * * * * * * * * * * * * * * * * * highwayman.” —Anthony Taylor |
> Ben Finney


Hi Ben,

Thanks for your feedback. My question is: Who owns this forum? If we
all do then we are allowed to post questions that are simple and that
could otherwise be answered by doing research. It is just unfriendly
to tell someone to go and look it up by themselves. Who is licensed to
judge what can and cannot be posted as a question? A teacher of mine
used to say: "There are no stupid questions, there are only stupid
answers." It is arrogant to tell someone in a Forum to "look it up
yourself ,this question is too basic". Can you not understand that
accessing a file can seem daunting at first? Believe me, documentation
can be offputting too when you only start with programming. Per se the
beauty of forums like these is that there are human beings willing to
make such tasks as finding out how to access a text file less 'scary'.
Whoever thinks he or she has a license to tell someone to look up the
answer by themselves should think again. I reckon the only license we
have is not to answer at all. I acknowledge that Benjamin pointed me
to the right place to find an answer but somehow the "Please do us a
favour" sounded bit arrogant, as if he owned the place (same goes for
all those who sided against me here: do you own this forum?)...i'd be
glad if there was a python for beginners forum but in the meantime i
have to say i find it awesome to have this forum to get help. It makes
a BIG difference. So sorry if i upset anyone, we all have our opinions
and get carried away and can be stubborn, i DO respect everyone in
this forum and i think it goes bothways. I've learned a few things in
this post...

So now, to use Benjamin words: Please do me a favour and let's move
on

Baba

Baba

 
Reply With Quote
 
Paul Rubin
Guest
Posts: n/a
 
      09-08-2010
Baba <> writes:
> It is just unfriendly
> to tell someone to go and look it up by themselves.


Someone seeing too many unthoughtful questions from you might tell you
to look it up yourself, in the hopes of getting you to change your
questioning style, so that your future questions will be more thoughtful
and worth answering. But according to you that would be unfriendly.

Another thing they could do is say nothing, but quietly configure their
news-reading software to ignore your questions completely. Then none of
your future questions would have any hope of being answered. Would that
be less unfriendly, or more unfriendly?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I tell the difference between the end of a text file, and an empty line in a text file? walterbyrd Python 7 05-17-2007 06:02 AM
Re: text file search to text file output possible? Whiskers Computer Support 3 10-07-2006 06:32 PM
Re: text file search to text file output possible? Mitch Computer Support 0 10-06-2006 11:15 PM
Read Text File and split them to individual text file Krish ASP .Net 1 10-20-2005 03:39 PM
Accessing a TEXT file =?Utf-8?B?WWFtYQ==?= ASP .Net 1 01-30-2004 08:36 PM



Advertisments