if os.path.isfile(i): ... print "file" ... else: ... print "directory" ...
> Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body 'help' to > [EMAIL PROTECTED] > > You can reach the person managing the list at > [EMAIL PROTECTED] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tutor digest..." > > > Today's Topics: > > 1. Re: terminology question (Kent Johnson) > 2. Corrupt files (?yvind) > 3. Re: Color text in Text widget (sunny sunny) > 4. Directory or File ? (Damien) > 5. Re: Directory or File ? (Kent Johnson) > 6. Re: Directory or File ? (Wolfram Kraus) > 7. Re: Directory or File ? (Damien) > 8. time.sleep() error (sunny sunny) > 9. Re: time.sleep() error (Kent Johnson) > 10. Re: time.sleep() error (sunny sunny) > 11. Re: time.sleep() error (geon) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 02 Aug 2005 07:06:32 -0400 > From: Kent Johnson <[EMAIL PROTECTED]> > Subject: Re: [Tutor] terminology question > Cc: "tutor@python.org" <tutor@python.org> > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > [EMAIL PROTECTED] wrote: >> Quoting Dick Moores <[EMAIL PROTECTED]>: >> >> >>>Why are list comprehensions called that? >> >> >> Because that's what they're called in Haskell, I guess.. >> >> It's historical, based on the term "set comprehension" from mathematics, >> also >> known as "set builder notation": >> http://en.wikipedia.org/wiki/Set_comprehension > > The Wikipedia page on "list comprehension" explicitly makes the connection > to "set comprehension" and shows how the math notation and Haskell syntax > resemble each other. > http://en.wikipedia.org/wiki/List_comprehension > > Kent > > > > ------------------------------ > > Message: 2 > Date: Tue, 2 Aug 2005 15:12:11 +0200 (CEST) > From: ?yvind <[EMAIL PROTECTED]> > Subject: [Tutor] Corrupt files > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain;charset=iso-8859-1 > > Hello. > > I have created a program that automatically downloads some files I need. > It can be .zip, .jpg, .mpg or .txt. However, a lot of the time urlretrieve > downloads the file, gives no error, but the downloaded file is corrupted. > I use a simple check for the size of the file. If it is way too small, I > automatically remove it. The files are ok on the server. > > Is there some function/modulte that checks a files integrity wheter or not > the file is corrupt or not? > > Thanks in advance. > > -- > This email has been scanned for viruses & spam by Decna as - www.decna.no > Denne e-posten er sjekket for virus & spam av Decna as - www.decna.no > > > > ------------------------------ > > Message: 3 > Date: Tue, 2 Aug 2005 09:40:31 -0400 > From: sunny sunny <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Color text in Text widget > To: [EMAIL PROTECTED] > Cc: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1 > > Thanks. > Its works very well. > Santosh. > > On 8/1/05, Jorge Louis de Castro <[EMAIL PROTECTED]> wrote: >> I found a way to do it but I'm not sure it is the cleanest. Maybe >> someone >> else on this list can offer a better solution. >> >> I use the text's configuration to define tags that I apply to sections >> of >> the text. For example: >> >> txtBox = Text(self, width=80, height=20) >> # configuration for red >> txtBox.tag_config("r", foreground="red") >> # configuration for blue >> txtBox.tag_config("b", foreground="blue") >> >> txtBox.insert(END,"I am red ", "r") >> txtBox.insert(END,"and I am blue\n", "b") >> >> Hope that helps >> jorge >> >> >From: sunny sunny <[EMAIL PROTECTED]> >> >To: tutor@python.org >> >Subject: [Tutor] Color text in Text widget >> >Date: Mon, 1 Aug 2005 15:35:52 -0400 >> > >> >Hi all, >> > >> >How do I add color to the text in the Text widget? I tried using the >> >ASCII sequence but it didnt work. >> > >> >For example, I want to add: >> > This is <Red> red <Red>, but this is <Blue> blue <Blue> >> > >> >Thanks. >> >Santosh. >> >_______________________________________________ >> >Tutor maillist - Tutor@python.org >> >http://mail.python.org/mailman/listinfo/tutor >> >> >> > > > ------------------------------ > > Message: 4 > Date: Tue, 02 Aug 2005 16:11:20 +0200 > From: Damien <[EMAIL PROTECTED]> > Subject: [Tutor] Directory or File ? > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Hi all, > I want to know if a file is a directory or a simple file. > I have done a little ugly script : > # i is my filename, os is imported > old = os.getcwd() > try: > chdir(i) > is_dir = True > except: > is_dir = False > os.chdir(old) > return is_dir > > But maybe there is a better way ? > If you know a better way, please tell me. > > Thanks, > Damien G. > > > ------------------------------ > > Message: 5 > Date: Tue, 02 Aug 2005 10:21:10 -0400 > From: Kent Johnson <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Directory or File ? > Cc: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Damien wrote: >> Hi all, >> I want to know if a file is a directory or a simple file. > > Look at os.path.isdir() > > Kent > >> I have done a little ugly script : >> # i is my filename, os is imported >> old = os.getcwd() >> try: >> chdir(i) >> is_dir = True >> except: >> is_dir = False >> os.chdir(old) >> return is_dir >> >> But maybe there is a better way ? >> If you know a better way, please tell me. >> >> Thanks, >> Damien G. >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> http://mail.python.org/mailman/listinfo/tutor >> > > > > ------------------------------ > > Message: 6 > Date: Tue, 02 Aug 2005 16:27:19 +0200 > From: Wolfram Kraus <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Directory or File ? > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=us-ascii; format=flowed > > Damien wrote: >> Hi all, >> I want to know if a file is a directory or a simple file. >> I have done a little ugly script : >> # i is my filename, os is imported >> old = os.getcwd() >> try: >> chdir(i) >> is_dir = True >> except: >> is_dir = False >> os.chdir(old) >> return is_dir >> >> But maybe there is a better way ? >> If you know a better way, please tell me. >> >> Thanks, >> Damien G. > > Use os.path.isdir: > http://python.org/doc/2.4.1/lib/module-os.path.html#l2h-1739 > > HTH, > Wolfram > > > > ------------------------------ > > Message: 7 > Date: Tue, 02 Aug 2005 18:00:07 +0200 > From: Damien <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Directory or File ? > To: Kent Johnson <[EMAIL PROTECTED]>, Wolfram Kraus > <[EMAIL PROTECTED]> > Cc: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" > > Ok, sorry. In the future, I will look more closely the module before > sending my question. > Thanks. > > Kent Johnson a ?crit : > >>Damien wrote: >> >> >>>Hi all, >>>I want to know if a file is a directory or a simple file. >>> >>> >> >>Look at os.path.isdir() >> >>Kent >> >> >> >>>I have done a little ugly script : >>># i is my filename, os is imported >>>old = os.getcwd() >>>try: >>> chdir(i) >>> is_dir = True >>>except: >>> is_dir = False >>>os.chdir(old) >>>return is_dir >>> >>>But maybe there is a better way ? >>>If you know a better way, please tell me. >>> >>>Thanks, >>>Damien G. >>>_______________________________________________ >>>Tutor maillist - Tutor@python.org >>>http://mail.python.org/mailman/listinfo/tutor >>> >>> >>> >> >>_______________________________________________ >>Tutor maillist - Tutor@python.org >>http://mail.python.org/mailman/listinfo/tutor >> >> >> > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.python.org/pipermail/tutor/attachments/20050802/b0b6ad7c/attachment-0001.htm > > ------------------------------ > > Message: 8 > Date: Tue, 2 Aug 2005 12:10:59 -0400 > From: sunny sunny <[EMAIL PROTECTED]> > Subject: [Tutor] time.sleep() error > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi all, > > I am using time.sleep to stop my program execution for some time. I > have imported time and am able to use it sucessfully in the main > program. > > However if I use it in any function I get the following error: > > the time.sleep(1) command generates this error : > TypeError : 'int' object is not callable > > I have tried to add import time after the function definition, it > still does not work. Please help. > > Thanks. > Santosh > > > ------------------------------ > > Message: 9 > Date: Tue, 02 Aug 2005 12:24:15 -0400 > From: Kent Johnson <[EMAIL PROTECTED]> > Subject: Re: [Tutor] time.sleep() error > Cc: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > sunny sunny wrote: >> Hi all, >> >> I am using time.sleep to stop my program execution for some time. I >> have imported time and am able to use it sucessfully in the main >> program. >> >> However if I use it in any function I get the following error: >> >> the time.sleep(1) command generates this error : >> TypeError : 'int' object is not callable >> >> I have tried to add import time after the function definition, it >> still does not work. Please help. > > It looks like somehow the name time.sleep has been bound to an integer. > Please post the code and the full error trace. > > Kent > > > > ------------------------------ > > Message: 10 > Date: Tue, 2 Aug 2005 12:27:27 -0400 > From: sunny sunny <[EMAIL PROTECTED]> > Subject: Re: [Tutor] time.sleep() error > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1 > > Some additional information: > > I am calling this function from a thread and I get the error. > However if I call the function from the main program it works fine. > > I am using thread.start_new_thread() to start the thread. > > Thanks. > Santosh. > > On 8/2/05, sunny sunny <[EMAIL PROTECTED]> wrote: >> Hi all, >> >> I am using time.sleep to stop my program execution for some time. I >> have imported time and am able to use it sucessfully in the main >> program. >> >> However if I use it in any function I get the following error: >> >> the time.sleep(1) command generates this error : >> TypeError : 'int' object is not callable >> >> I have tried to add import time after the function definition, it >> still does not work. Please help. >> >> Thanks. >> Santosh >> > > > ------------------------------ > > Message: 11 > Date: Tue, 02 Aug 2005 18:35:21 +0200 > From: geon <[EMAIL PROTECTED]> > Subject: Re: [Tutor] time.sleep() error > To: Tutor Python <tutor@python.org> > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > sunny sunny napsal(a): > >>Hi all, >> >>I am using time.sleep to stop my program execution for some time. I >>have imported time and am able to use it sucessfully in the main >>program. >> >>However if I use it in any function I get the following error: >> >>the time.sleep(1) command generates this error : >>TypeError : 'int' object is not callable >> >> >> > > Dont you actually have something like this?: > > from time import * > > # somewhere you use sleep like this > sleep=10 > > # and then > sleep(1) > > # you get: > # sleep(1) > #TypeError: 'int' object is not callable > > In this case you "overwrite" the original function sleep() with your/my > variable sleep.... > Solution: rename your/my variable sleep to f.e. notAwake=10 :-) > > -- > geon > > > > > > ------------------------------ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > End of Tutor Digest, Vol 18, Issue 16 > ************************************* > > -- > Sistema Antivirus INFOSUR > Mailscanner - www.mailscanner.org > Enrique Acosta Figueredo Programador, Linux User # 391079 (http://counter.li.org) -- Sistema Antivirus INFOSUR Mailscanner - www.mailscanner.org _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor