[Tutor] Repply

2008-12-26 Thread prasad rao
Thanks for help. > http://svn.python.org/view/python/trunk/Objects/listobject.c?rev=67498&view=markup Kent ! This is grek and latin to me.From the presence of header files it looks C++.But headerfiles are not between '<' and '>' . >But why are you trying to sort in this fashion? Alan Gauld!

Re: [Tutor] commands versus subprocess, I'm confused

2008-12-26 Thread Reed O'Brien
On Dec 26, 2008, at 8:57, "Emad Nawfal (عماد نوفل)" mail.com> wrote: 2008/12/26 Kent Johnson On Fri, Dec 26, 2008 at 8:09 AM, Emad Nawfal (عماد نوفل) wrote: > suppose I have an external program that prints "testing the subprocess > module" > I know I can run it through the commands module

Re: [Tutor] commands versus subprocess, I'm confused

2008-12-26 Thread Alan Gauld
"Emad Nawfal (عماد نوفل)" wrote proc = subprocess.Popen('python3.0 hello.py', shell=True, stdout=subprocess.PIPE, ) stdout_value = proc.communicate()[0] Thank you Kent. It works, but isn't the commands module much simpler? I

Re: [Tutor] beginsWith multiple prefixes

2008-12-26 Thread ALAN GAULD
> I simply prefer the built-in one. I had no idea it could take a tuple. Me neither, that was a surprise goody in 2.5 that I hadn't seen before. > What is amazing is that I learn more from this list than I do from any other > source. Me too, and I've been subscribed for over 10 years now

Re: [Tutor] commands versus subprocess, I'm confused

2008-12-26 Thread Emad Nawfal (عماد نوفل)
2008/12/26 Kent Johnson > On Fri, Dec 26, 2008 at 8:09 AM, Emad Nawfal (عماد نوفل) > wrote: > > suppose I have an external program that prints "testing the subprocess > > module" > > I know I can run it through the commands module like this: > > > a = commands.getoutput("python3.0 hello.py"

Re: [Tutor] commands versus subprocess, I'm confused

2008-12-26 Thread Kent Johnson
On Fri, Dec 26, 2008 at 8:09 AM, Emad Nawfal (عماد نوفل) wrote: > suppose I have an external program that prints "testing the subprocess > module" > I know I can run it through the commands module like this: > a = commands.getoutput("python3.0 hello.py") a > 'testing the subprocess modul

Re: [Tutor] to sort

2008-12-26 Thread Kent Johnson
On Fri, Dec 26, 2008 at 1:21 AM, prasad rao wrote: > By the way how can I view the builtin code for sort method? Look at the source - Objects/listobject.c - starting at the comment "Lots of code for an adaptive, stable, natural mergesort." http://svn.python.org/view/python/trunk/Objects/listobje

Re: [Tutor] beginsWith multiple prefixes

2008-12-26 Thread Emad Nawfal (عماد نوفل)
On Fri, Dec 26, 2008 at 6:47 AM, Alan Gauld wrote: > > "Kent Johnson" wrote > >> for d in os.listdir(): >>> if MyString(d).upper().beginswith(): >>> >> >> But that won't work, the result of calling upper() will be a normal >> str, not a MyString. >> > > Ah yes. Immutability of strings strike

[Tutor] commands versus subprocess, I'm confused

2008-12-26 Thread Emad Nawfal (عماد نوفل)
Hello Tutors, and Happy New Year and Holidays, suppose I have an external program that prints "testing the subprocess module" I know I can run it through the commands module like this: >>> a = commands.getoutput("python3.0 hello.py") >>> a 'testing the subprocess module' >>> len(a) 29 >>> b = a.sp

Re: [Tutor] to sort

2008-12-26 Thread Alan Gauld
"prasad rao" wrote a=[21,56,35,47,94,12] b=[] for x in a: b.append (min(a)) a.remove (min(a)) It is not Compleating .Doing only 3 rounds.Why? Think about what is happening. for x in a x takes the next value of x after each iteration. Each iteration reduces the size of a so a

Re: [Tutor] beginsWith multiple prefixes

2008-12-26 Thread Alan Gauld
"Kent Johnson" wrote for d in os.listdir(): if MyString(d).upper().beginswith(): But that won't work, the result of calling upper() will be a normal str, not a MyString. Ah yes. Immutability of strings strikes again. upper() returns a new string, I forgot about that. pity. You ca