On 11/12/05, Danny Yoo <[EMAIL PROTECTED]> wrote:
> > > > from the code:
> > > > try:
> > > > fsock = open("c:/TEMP/hello.txt")
> > > > except IOError:
> > > > print "The file does not exist, exiting gracefully"
> > > > print "Yes!!! This line will always print"
>
> > I thought if the excep
> > > from the code:
> > > try:
> > > fsock = open("c:/TEMP/hello.txt")
> > > except IOError:
> > > print "The file does not exist, exiting gracefully"
> > > print "Yes!!! This line will always print"
> I thought if the except situation does not happen, that means the try
> section works.
On 11/12/05, Danny Yoo <[EMAIL PROTECTED]> wrote:
> > > 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 n
> > 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:
>
>fsock = open("c:/TEMP/hello.txt")
This opens the file ready for you to read it.
Thats all. You need to tell Python what you want to do with the file now
that you've opened it.
> why it does not show on the output.
To display the contents you need
print fsock.read()
Have a look at the Han
On 11/12/05, Liam Clarke <[EMAIL PROTECTED]> wrote:
> Sorry Shi Mu, don't understand the question.
>
> So, you're successfull opening a file. Now, you need to read it
>
> for line in fsock:
>print line
>
> or
>
> fsockData = fsock.read()
>
> or
>
> nextLine = fsock.readline()
>
> Have a play wi
Sorry Shi Mu, don't understand the question.
So, you're successfull opening a file. Now, you need to read it
for line in fsock:
print line
or
fsockData = fsock.read()
or
nextLine = fsock.readline()
Have a play with those.
On 11/12/05, Shi Mu <[EMAIL PROTECTED]> wrote:
> I got the output
I got the output as:
>>>
Yes!!! This line will always print
from the code:
try:
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
Shi Mu wrote:
> I found the code for class "now". I got confused by two things:
> First, how did the former code I posted know to import tis module of "Now";
You told it to with the statement
import now
This statement tells Python to look in the directories in its path for a file
called now.py
On 10/14/05, Shi Mu <[EMAIL PROTECTED]> wrote:
I found the code for class "now". I got confused by two things:First, how did the former code I posted know to import tis module of "Now";Second. what does "\" mean following "self.year
,"Thanks a lot!class now: def __str__(self):return ti
I found the code for class "now". I got confused by two things:
First, how did the former code I posted know to import tis module of "Now";
Second. what does "\" mean following "self.year,"
Thanks a lot!
class now:
def __init__(self):
self.t = time.time()
self.storetime()
d
Shi Mu wrote:
> After I run the following python code, I expect to have the printing such as:
> The year is 2005
>
> However, I got something like:
> The year is 2005
> Fri Oct 14 17:43:31 2005
> Fri Oct 14 17:43:31 2005
> The year is 2005
>
> What is the reason?
Maybe coming from module 'now'?
After I run the following python code, I expect to have the printing such as:
The year is 2005
However, I got something like:
The year is 2005
Fri Oct 14 17:43:31 2005
Fri Oct 14 17:43:31 2005
The year is 2005
What is the reason?
The code follows:
import time
import now
class today(now.now):
13 matches
Mail list logo