Re: [Tutor] about recursion code

2004-12-06 Thread Guillermo Fernandez Castellanos
Usually, in case of doubt, use a debugger or print statements: def selection_sort(lst,start,end): """sort the lst from selection start to end""" print lst, start, end if len(lst)==1: print "list of size 1" return lst elif lst=="":

[Tutor] about recursion code

2004-12-06 Thread Lin Jin
hello,tutors: i am working on the recursion of selection sort,and my code is: def selection_sort(lst,start,end): """sort the lst from selection start to end""" if len(lst)==1: return lst elif lst=="": return "" else: return lst[:start]+selection_sort(lst,start+1,en

Re: [Tutor] Address book sort of

2004-12-06 Thread Isr Gish
It was posted recently that pickleing should use binary mode. See changes in code. Rick Muller wrote: > >from cPickle import load, dump > >def save(fname,addressbook): >file = open(filename,'w') file = open(filename,'wb') >dump(addressbook,file) >file.close()

Re: [Tutor] Simple RPN calculator

2004-12-06 Thread Terry Carroll
On Mon, 6 Dec 2004, Chad Crabtree wrote: > Bob Gailer wrote: > > > For grins I just wrote one that takes '1 2.3 - 3 4 5 + * /' as > input > > and prints -0.0481481 8 lines of Python. That indeed is less > than > > 100. Took about 7 minutes to code and test. > > I'm quite interested in see

Re: [Tutor] eval and exec

2004-12-06 Thread Alan Gauld
> > - MS allows Outlook to run scripts when mail is open, if > > those scripts are harmful we have a virus! That is (was, they've improved it a lot) the number one cause of script kiddie virii. Simply viewing a mail message in the preview pane was enough to trigger a script. They have improved s

Re: [Tutor] Removing a row from a tab delimitted text

2004-12-06 Thread Danny Yoo
On Mon, 6 Dec 2004, kumar s wrote: > Here is how my file looks: > > Name=3492_at > Cell1=481 13 (The space between (481 and 13 is tab) > Cell1=481 13 > Cell1=481 13 > Name=1001_at > Cell1=481 13 > Cell2=481 12 > Cell1=481 13 > Cell1=481 13 > Cell2=481 12 > Name=1002_at > Cell3=482 12 > Cell1=481

RE: [Tutor] Removing a row from a tab delimitted text

2004-12-06 Thread Kooser, Ara S
Alan Gauld tutorial at http://www.freenetpages.co.uk/hp/alan.gauld/ has some examples in python that will solve this problem. Happy Pythoning Ara "There is something to be learned from a rainstorm. When meeting with a sudden shower, you try not to get wet and run quickly along the road. But do

[Tutor] Removing a row from a tab delimitted text

2004-12-06 Thread kumar s
Dear group, I have a file, with Name identifier followed by two columns with numbers. Here is how my file looks: Name=3492_at Cell1=481 13 (The space between (481 and 13 is tab) Cell1=481 13 Cell1=481 13 Name=1001_at Cell1=481 13 Cell2=481 12 Cell1=481 13 Cell1=481 13 Cell2=481 12 Name=1002_a

Re: [Tutor] Simple RPN calculator

2004-12-06 Thread Andreas Kostyrka
Am Mo, den 06.12.2004 schrieb Chad Crabtree um 14:05: > Bob Gailer wrote: > > > For grins I just wrote one that takes '1 2.3 - 3 4 5 + * /' as > input > > and prints -0.0481481 8 lines of Python. That indeed is less > than > > 100. Took about 7 minutes to code and test. > > I'm quite inter

Re: [Tutor] Finding a part of an element in a list

2004-12-06 Thread Liam Clarke
Hey Kumar, nearly there - List1 = ['Tyres','windsheild','A\CUnit','Model=Toyota_Corolla'] In other list I have : List2= ['Corolla','Accord','Camry'] for element1 in List1: for element2 in List2: if element2 in element1: #Do something here, usually a break or conti

[Tutor] Finding a part of an element in a list

2004-12-06 Thread kumar s
Dear Group, I have a list that is: List1 = ['Tyres','windsheild','A\CUnit','Model=Toyota_Corolla'] In other list I have : List2= ['Corolla','Accord','Camry'] I want to see if Corolla is there in list 1: The code: for i in range(len(List1)): if i in range(len(List2): print i

RE: [Tutor] Socket events and wxPython events?

2004-12-06 Thread Christian Wyglendowski
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Mike Eve > Sent: Sunday, December 05, 2004 6:21 PM > To: [EMAIL PROTECTED] > Subject: [Tutor] Socket events and wxPython events? Hey Mike, > I'm thinking about 3 approaches, but rather than beat m

[Tutor] Re: Can I see it?

2004-12-06 Thread Bob Gailer
At 02:06 PM 12/5/2004, Just Incase wrote: Hi Bob, Yea, it is a homework and I would also like to do something on it to get familiar with the program, so all I am asking for is if there are the pionters to help me. Like I said I am new to python/programming but I have limited time to turn-in the

Re: [Tutor] CGI Video collection application File I/O troubles

2004-12-06 Thread Chad Crabtree
Olli Rajala wrote: > > > >>Ok. I tried running the script on my Apache server on Windows NT and IT >>WORKS The script saves the values of videodb keys correctly. DARN!!! >>I don't get it. Why does the exact same script work on Win and not on Linux. >> >>Oh, did I mention I am developing the

Re: [Tutor] CGI Video collection application File I/O troubles

2004-12-06 Thread Olli Rajala
> Ok. I tried running the script on my Apache server on Windows NT and IT > WORKS The script saves the values of videodb keys correctly. DARN!!! > I don't get it. Why does the exact same script work on Win and not on Linux. > > Oh, did I mention I am developing the application on Linux. And

Re: [Tutor] Simple RPN calculator

2004-12-06 Thread Chad Crabtree
Bob Gailer wrote: > For grins I just wrote one that takes '1 2.3 - 3 4 5 + * /' as input > and prints -0.0481481 8 lines of Python. That indeed is less than > 100. Took about 7 minutes to code and test. I'm quite interested in seeing the sourcecode for that. __

Re: [Tutor] psyco 1.3 is out, with support for Python 2.4

2004-12-06 Thread Kent Johnson
Dick Moores wrote: Here's what I learned from Kent about installing psyco (for Windows): Download psyco from http://psyco.sourceforge.net. Unzip the zip file. Copy the folder psyco-1.3/psyco into Python24/Lib/site-packages. (Create site-packages if you don't already have it.) Should be good to go

Re: [Tutor] CGI Video collection application File I/O troubles

2004-12-06 Thread Guybrush Threepwood
Quoting "Jacob S." <[EMAIL PROTECTED]>: > Your error message says that you are getting an empty string from your cgi > variable. I IMHO would suggest printing videodb['title'] before writing it > to a file to see what the variable contains. Or you might print out videodb > to see what the dictiona

[Tutor] Re: Could I have used time or datetime modules here?

2004-12-06 Thread Liam Clarke
Hey Dick, don't know if anyone actually answered your original question. >IOW, is there an easier way to calculate the time difference between the >time now, say 08:51 and say, tomorrow at 03:45, to take an example of the >most difficult case? So, you need two datetime.datetime objects. >>>now =

Re: [Tutor] psyco 1.3 is out, with support for Python 2.4

2004-12-06 Thread Dick Moores
Liam, Kent Johnson was of great help in getting me started with psyco. psyco's easy to implement, it seems, and can make an enormous difference in speed. The best example I've seen is my simple , where psyco speeds up the tiny while loop of spin(), wh

Re: [Tutor] Address book sort of

2004-12-06 Thread R. Alan Monroe
> spaceMult=(highLength+minimumSpaces)-len(key) > outString=str(index)+". "+key+(spaceMult * " ") + item > print outString > while len(display_name) < 25: > display_name += '.' > count += 1 > print count, display_name, d[item]

Re: [Tutor] Address book sort of

2004-12-06 Thread justinstraube
>> How do i pretty print output of dictionary container? Sort of tabular >> form or something, e.g., >> >> 1. name1email address1 >> 2. name2email address2 >> >> Just for my learning experience :-). Thanks! [Liam Clarke] highLength=0 for element in myDict.keys(): if len(eleme

Re: [Tutor] psyco 1.3 is out, with support for Python 2.4

2004-12-06 Thread Liam Clarke
Have you used Pysco much Dick? Is it n00bie friendly? Or, to put it another way, at what point in a programme's size/speed does it become worthwhile to implement Pysco? Regards, Liam Clarke On Sun, 05 Dec 2004 23:49:03 -0800, Dick Moores <[EMAIL PROTECTED]> wrote: >

[Tutor] psyco 1.3 is out, with support for Python 2.4

2004-12-06 Thread Dick Moores
And "The Ultimate Psyco Guide" for 1.3 is at Dick Moores ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor