Re: [Tutor] output question

2005-11-12 Thread Shi Mu
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

Re: [Tutor] output question

2005-11-12 Thread Danny Yoo
> > > 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.

Re: [Tutor] output question

2005-11-12 Thread Shi Mu
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

Re: [Tutor] output question

2005-11-12 Thread Danny Yoo
> > 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: >

Re: [Tutor] output question

2005-11-12 Thread Alan Gauld
>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

Re: [Tutor] output question

2005-11-12 Thread Shi Mu
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

Re: [Tutor] output question

2005-11-12 Thread Liam Clarke
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

Re: [Tutor] output question

2005-10-14 Thread Kent Johnson
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

Re: [Tutor] output question

2005-10-14 Thread w chun
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

Re: [Tutor] output question

2005-10-14 Thread Shi Mu
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

Re: [Tutor] output question

2005-10-14 Thread Kent Johnson
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'?