[Tutor] output question
dyoo at hkn.eecs.berkeley.edu
Sat Nov 12 19:11:47 CET 2005
> > So, you're successfull opening a file. Now, you need to read it
> > for line in fsock:
> > print line
> > Have a play with those.
> it works! thanks!
Hi Shi Mu,
Ok, but let's go back to your original question now, just to make sure
we've learned something. You asked earlier:
> from the code:
> fsock = open("c:/TEMP/hello.txt")
> except IOError:
> print "The file does not exist, exiting gracefully"
> print "Yes!!! This line will always print"
> it means the code found there is hello.txt, why it does not show on the
Do you know now why the original code didn't do what you want? Can you
explain why? I know it's seems like a silly question, but we are trying
to avoid a cargo-cult attitude here. What knowledge did you learn?
Again, I'm really not getting any sense whatsoever of knowing why you had
difficulty here. Personally, if I run into difficulty with a problem,
even if I hack out something that "works", I'm not satisified until I
understand the reasons why I got stuck. I've been bitten too many times
by being satisifed by the "right" answer for the wrong reasons. *grin*
More information about the Tutor