Re: [Tutor] Help return a pattern from list

2010-07-05 Thread Emile van Sebille
On 7/5/2010 4:19 PM Alan Gauld said... But for the specific case of file extensions the os.path.splitext() is a better solution. If, as the names suggest, the source is the file system, then I'd reach for glob. Emile ___ Tutor maillist - Tu

Re: [Tutor] Help return a pattern from list

2010-07-05 Thread Thomas C. Hicks
On Mon, 05 Jul 2010 20:29:02 +0200 tutor-requ...@python.org wrote: > Date: Mon, 5 Jul 2010 13:54:55 -0400 > From: Vineeth Rakesh > To: tutor@python.org > Subject: [Tutor] Help return a pattern from list > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > Hello all, > > C

Re: [Tutor] Help return a pattern from list

2010-07-05 Thread Alan Gauld
"Shashwat Anand" wrote list = ["something1.mp3","something2.mp3","something4.pdf","something5.odt"] [i for i in list if i[-4:] == '.mp3'] ['something1.mp3', 'something2.mp3'] Or even easier: [s for s in list if s.endswith('.mp3')] But for the specific case of file extensions the os.pa

[Tutor] the ball needs a kick...

2010-07-05 Thread Schoap D
Hi, I'm doing the exercises here: chapter 8 http://www.openbookproject.net/thinkCSpy/ch08.html Now I have added another paddle to the pong game. So far so good, but the ball isn't moving anymore and I am not able to fix it... Any comments, tips, feedback? Thanks in advance, http://paste.pocoo.o

Re: [Tutor] Help return a pattern from list

2010-07-05 Thread Shashwat Anand
On Mon, Jul 5, 2010 at 11:58 PM, Shashwat Anand wrote: > > > On Mon, Jul 5, 2010 at 11:24 PM, Vineeth Rakesh > wrote: > >> Hello all, >> >> Can some one help me to return a special pattern from a list. >> >> say list = >> ["something1.mp3","something2.mp3","something4.pdf","something5.odt"] >> >

Re: [Tutor] Help return a pattern from list

2010-07-05 Thread Shashwat Anand
On Mon, Jul 5, 2010 at 11:24 PM, Vineeth Rakesh wrote: > Hello all, > > Can some one help me to return a special pattern from a list. > > say list = > ["something1.mp3","something2.mp3","something4.pdf","something5.odt"] > One suggestion. Don't name a list as list. Use l or List or any other vari

Re: [Tutor] Help return a pattern from list

2010-07-05 Thread Sander Sweers
On 5 July 2010 19:54, Vineeth Rakesh wrote: > Can some one help me to return a special pattern from a list. > > say list = > ["something1.mp3","something2.mp3","something4.pdf","something5.odt"] > > now say I just need to return the files with .mp3 extension. How to go about > doing this? Use os.

[Tutor] Help return a pattern from list

2010-07-05 Thread Vineeth Rakesh
Hello all, Can some one help me to return a special pattern from a list. say list = ["something1.mp3","something2.mp3","something4.pdf","something5.odt"] now say I just need to return the files with .mp3 extension. How to go about doing this? Thanks Vin _

Re: [Tutor] endless loop

2010-07-05 Thread Alan Gauld
"prasad rao" wrote def rr(z,m=1): q=lambda n:m%n==0 s=lambda False : 0 This is always false??? a=filter(s,map(q,range(1,z))) So this is always empty? if not a: So this is always true m+=1 rr(z,m) So you contuinuaslly

Re: [Tutor] Running a python script as root.

2010-07-05 Thread Eike Welk
Hello Srihari! On Sunday July 4 2010 20:17:12 Srihari k wrote: > I did #chmod +s settime.py so that SUID bit be set and all users can > execute the script and set the system time. > now the permissions of file are: > -rwsr-xr-x 1 root root 165 2010-07-04 23:16 settime.py > > > The script still w

Re: [Tutor] raw_input

2010-07-05 Thread Sander Sweers
On 5 July 2010 17:40, Shashwat Anand wrote: > use input() instead of raw_input() in Python3.x To add to this, in Python 2 we had input() [1] (unsafe for most uses) and raw_input() [2] (safe). Python 3 removed the old input() and renamed raw_input() to input() [3,4]. Greets Sander [1] http://doc

Re: [Tutor] endless loop

2010-07-05 Thread Emile van Sebille
On 7/5/2010 8:31 AM prasad rao said... hi I am trying problem 6 in projecteuler.org. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? def rr(z,m=1): q=lambda n:m%n==0 s=lambda False : 0 a=filter(s,map(q,range(1

Re: [Tutor] raw_input

2010-07-05 Thread Dipo Elegbede
Tried it out and it worked. Thanks. Regards, On 7/5/10, Shashwat Anand wrote: > use input() instead of raw_input() in Python3.x > > On Mon, Jul 5, 2010 at 8:50 PM, Dipo Elegbede wrote: > >> Hello, >> >> I seem to be having problems with raw_input. >> >> i wrote something like: >> >> raw_input('P

Re: [Tutor] raw_input

2010-07-05 Thread Shashwat Anand
use input() instead of raw_input() in Python3.x On Mon, Jul 5, 2010 at 8:50 PM, Dipo Elegbede wrote: > Hello, > > I seem to be having problems with raw_input. > > i wrote something like: > > raw_input('Press Enter') > > it comes back to tell me raw_input is not defined, a NameError! > > Is it th

[Tutor] endless loop

2010-07-05 Thread prasad rao
hi I am trying problem 6 in projecteuler.org. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? def rr(z,m=1): q=lambda n:m%n==0 s=lambda False : 0 a=filter(s,map(q,range(1,z))) if not a: m+=1

[Tutor] raw_input

2010-07-05 Thread Dipo Elegbede
Hello, I seem to be having problems with raw_input. i wrote something like: raw_input('Press Enter') it comes back to tell me raw_input is not defined, a NameError! Is it that something about it has changed in python 3.1 or I have been writing the wrong thing. Please enlighten me. regards.

Re: [Tutor] "x and y" means "if x is false, then x, else y"??

2010-07-05 Thread Steven D'Aprano
On Mon, 5 Jul 2010 07:37:12 pm Richard D. Moores wrote: > On Mon, Jul 5, 2010 at 00:55, Steve Willoughby wrote: [...] > Steve, > > Your answer seems very well-formulated. However, I've read it over > and over, but I keep getting hung up over the meaning of "the return > value" of an expression. I

Re: [Tutor] "x and y" means "if x is false, then x, else y"??

2010-07-05 Thread Adam Bark
On 5 July 2010 13:21, Adam Bark wrote: > On 5 July 2010 12:53, Richard D. Moores wrote: > >> On Mon, Jul 5, 2010 at 04:09, Stefan Behnel wrote: >> > Richard D. Moores, 05.07.2010 11:37: >> >> >> >> I keep getting hung up over the meaning of "the return >> >> value" of an expression. I am of cou

Re: [Tutor] "x and y" means "if x is false, then x, else y"??

2010-07-05 Thread Adam Bark
On 5 July 2010 12:53, Richard D. Moores wrote: > On Mon, Jul 5, 2010 at 04:09, Stefan Behnel wrote: > > Richard D. Moores, 05.07.2010 11:37: > >> > >> I keep getting hung up over the meaning of "the return > >> value" of an expression. I am of course familiar with values returned > >> by a funct

Re: [Tutor] "x and y" means "if x is false, then x, else y"??

2010-07-05 Thread Richard D. Moores
On Mon, Jul 5, 2010 at 04:54, Walter Prins wrote: > > > On 5 July 2010 08:27, Richard D. Moores wrote: >> >> See >> . >> I am quite familiar with the meaning of "x and y" in Python, and how >> it is evaluated -- firs

Re: [Tutor] "x and y" means "if x is false, then x, else y"??

2010-07-05 Thread Walter Prins
On 5 July 2010 08:27, Richard D. Moores wrote: > See < > http://docs.python.org/py3k/library/stdtypes.html#boolean-operations-and-or-not > >. > I am quite familiar with the meaning of "x and y" in Python, and how > it is evaluated -- first x, and only if x is False, then evaluate y. > Sorry if t

Re: [Tutor] "x and y" means "if x is false, then x, else y"??

2010-07-05 Thread Richard D. Moores
On Mon, Jul 5, 2010 at 04:09, Stefan Behnel wrote: > Richard D. Moores, 05.07.2010 11:37: >> >> I keep getting hung up over the meaning of "the return >> value" of an expression. I am of course familiar with values returned >> by a function, but don't quite grasp what the return value of, say, >>

Re: [Tutor] "x and y" means "if x is false, then x, else y"??

2010-07-05 Thread Stefan Behnel
Richard D. Moores, 05.07.2010 11:37: I keep getting hung up over the meaning of "the return value" of an expression. I am of course familiar with values returned by a function, but don't quite grasp what the return value of, say, the y of "x and y" might mean. Think of a different expression, l

Re: [Tutor] "x and y" means "if x is false, then x, else y"??

2010-07-05 Thread Richard D. Moores
On Mon, Jul 5, 2010 at 00:55, Steve Willoughby wrote: > On 05-Jul-10 00:27, Richard D. Moores wrote: >> >> >> See. >> I am quite familiar with the meaning of "x and y" in Python, and how >> it is evaluated -- first x,

Re: [Tutor] "x and y" means "if x is false, then x, else y"??

2010-07-05 Thread Steve Willoughby
On 05-Jul-10 00:27, Richard D. Moores wrote: See. I am quite familiar with the meaning of "x and y" in Python, and how it is evaluated -- first x, and only if x is False, then evaluate y. But I just can't read "if x

[Tutor] "x and y" means "if x is false, then x, else y"??

2010-07-05 Thread Richard D. Moores
See . I am quite familiar with the meaning of "x and y" in Python, and how it is evaluated -- first x, and only if x is False, then evaluate y. But I just can't read "if x is false, then x, else y" that way. In fact,