Re: [Tutor] Working with lists

2008-12-14 Thread Rich Lovely
Yeah, you could do that, but it was quite a revelation when I discovered itertools, and I'm just trying to share the love. --- Richard "Roadie Rich" Lovely Part of the JNP|UK Famille www.theJNP.com (Sent from my iPod - please allow me a few typos: it's a very small keyboard) On 14 Dec 2008

Re: [Tutor] reading inputs from keyboard

2008-12-14 Thread Sander Sweers
On Sun, Dec 14, 2008 at 18:21, Robert Berman wrote: > RTFM. Thank you for your non contribution python tutor mailing list.The minimum you could do is point to the FM which others luckily already did. Greets Sander ___ Tutor maillist - Tutor@python.or

Re: [Tutor] stable algorithm

2008-12-14 Thread Alan Gauld
"spir" wrote And how can i write single test which will tell me execution time of this algorithm? First, google will give you tons of links on the topic. time.time() returns present time in ms You could also use the python profiler which will give you timing information for just the sort f

Re: [Tutor] reading inputs from keyboard

2008-12-14 Thread Marc Tompkins
On Sun, Dec 14, 2008 at 10:48 AM, Robert Berman wrote: > > Rather than being impressed, perhaps you might consider performing the action. > > spir wrote: > > Robert Berman a écrit : > > RTFM. > > how clever! > I'm impressed... > Denis Also, you might have noticed that Denis wasn't the original po

Re: [Tutor] reading inputs from keyboard

2008-12-14 Thread Luke Paireepinart
A more gentle nudging in the correct direction is generally more well-received. Honestly, it doesn't help anyone to be rude, and we'll all just think less of you for this unnecessary divergence. If you're not going to at be witty and subtle about it, you may as well direct them to Eric Raymond's a

Re: [Tutor] reading inputs from keyboard

2008-12-14 Thread Robert Berman
Rather than being impressed, perhaps you might consider performing the action. spir wrote: Robert Berman a écrit : RTFM. how clever! I'm impressed... Denis ___ Tutor maillist - Tutor@python.org http://mail.python.org/

Re: [Tutor] stable algorithm

2008-12-14 Thread spir
David Hláčik a écrit : Hi, thank you very much. And how can i write single test which will tell me execution time of this algorithm? I need to write a table with number of data & execution time comparison (and it should be linear in case of this algorithm) Thanks! D. First, google will giv

Re: [Tutor] stable algorithm

2008-12-14 Thread David Hláčik
Hi, thank you very much. And how can i write single test which will tell me execution time of this algorithm? I need to write a table with number of data & execution time comparison (and it should be linear in case of this algorithm) Thanks! D. On Sun, Dec 14, 2008 at 5:58 PM, Alan Gauld wro

Re: [Tutor] reading inputs from keyboard

2008-12-14 Thread Robert Berman
RTFM. Ajo Augustine wrote: hi all; can u let me know how  to  read an input string  from the keyboard? -- Ajo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] stable algorithm

2008-12-14 Thread Alan Gauld
"David Hlácik" wrote yes it is homework , this is result : #! /usr/bin/python def sort(numbers): "sort n positive integers in O(n) provided that they are all < n^2" N = len(numbers) # get size of test numbers buckets_mod = [[] for i in xrange(N)] buckets_sorted =

Re: [Tutor] Working with lists

2008-12-14 Thread bob gailer
Paul McGuire wrote: Even simpler than Rich Lovely's: newlist = [a+b for a,b in itertools.izip(l1[:-1], l1[1:])] is to just use the built-in zip: newlist = [a+b for a,b in zip(l1[:-1], l1[1:])] And then there's good old reduce which sadly is going to be harder to access in Python

Re: [Tutor] stable algorithm

2008-12-14 Thread David Hláčik
> def sort(numbers): >"sort n positive integers in O(n) provided that they are all < n^2" Sorry about wrong comment, should be range from [1 to n^2] not only < n^2. D. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listin

Re: [Tutor] stable algorithm

2008-12-14 Thread David Hláčik
> > Does that mean its homework? > Hi, yes it is homework , this is result : #! /usr/bin/python def sort(numbers): "sort n positive integers in O(n) provided that they are all < n^2" N = len(numbers) # get size of test numbers buckets_mod = [[] for i in xrange(N)]

Re: [Tutor] reading inputs from keyboard

2008-12-14 Thread Alan Gauld
"Ajo Augustine" wrote can u let me know how to read an input string from the keyboard? If you need to ask that then you need to work through any of the many Python tutorials. They all cover this, usually fairly early in the course. Try some of those listed here: http://wiki.python.o

Re: [Tutor] stable algorithm

2008-12-14 Thread Alan Gauld
"David Hlácik" wrote this is for me life important problem which needs to be solved within next 12 hours.. Does that mean its homework? If so we can only offer pointers, but you need to tell us what you have done yourself first. If its not homework then please give a bit more background. W

[Tutor] Python Lib Files

2008-12-14 Thread btkuhn
Hello everyone, I discovered yesterday that the Python package has a number of built in example scripts in the /lib directory. Perhaps this is common knowledge but I did not know about it. I can't seem to find any kind of guide to the files, though. Is there a readme somewhere that someone can

Re: [Tutor] Working with lists

2008-12-14 Thread Paul McGuire
Even simpler than Rich Lovely's: newlist = [a+b for a,b in itertools.izip(l1[:-1], l1[1:])] is to just use the built-in zip: newlist = [a+b for a,b in zip(l1[:-1], l1[1:])] since you can be sure that l1[:-1] and l1[1:] will always be the same length, so there is no need for a fill valu

Re: [Tutor] reading inputs from keyboard

2008-12-14 Thread bob gailer
Ajo Augustine wrote: hi all; can u let me know how to read an input string from the keyboard? In Python 2.6 and lower: raw_input(prompt) Example program: name = raw_input("Enter your name:") print "Hello", name raw_input("Press any key to exit.") In Python 3 Example program: name = inp

[Tutor] reading inputs from keyboard

2008-12-14 Thread Ajo Augustine
hi all; can u let me know how to read an input string from the keyboard? -- Ajo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] stable algorithm

2008-12-14 Thread David Hláčik
Hi guys, i am really sorry for making offtopic, hope you will not kill me, but this is for me life important problem which needs to be solved within next 12 hours.. I have to create stable algorithm for sorting n numbers from interval [1,n^2] with time complexity O(n) . Can someone please give m