[Tutor] re: help/unsubscribe me please

AJGables@cs.com AJGables@cs.com
Thu Jun 19 12:13:15 2003


tutor-request@python.org wrote:

>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
>    tutor-request@python.org
>
>You can reach the person managing the list at
>    tutor-admin@python.org
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of Tutor digest..."
>
>
>Today's Topics:
>
>   1. Re: Can you create an image from Tkinter? (Alfred Milgrom)
>   2. Re: Using time module to count off seconds before an event (valhalla)
>   3. Re: why is list.pop(0) slow? (Alan Gauld)
>   4. Re: why is list.pop(0) slow? (Gregor Lingl)
>   5. Printing std.out (terminal) with formatted output (DAVID BABCOCK)
>   6. using select (Denis Dzyubenko)
>   7. Re: crash when importing random or sys module, in my
>       embedded python (Magnus =?iso-8859-1?Q?Lyck=E5?=)
>   8. Re: Printing std.out (terminal) with formatted output (Magnus =?iso-8859-1?Q?Lyck=E5?=)
>   9. TSR in windows (Patrick Kirk)
>  10. Re: TSR in windows (Magnus =?iso-8859-1?Q?Lyck=E5?=)
>
>--__--__--
>
>Message: 1
>Date: Thu, 19 Jun 2003 12:48:01 +1000
>To: Magnus =?iso-8859-1?Q?Lyck=E5?= <magnus@thinkware.se>,
>    tutor@python.org
>From: Alfred Milgrom <fredm@smartypantsco.com>
>Subject: Re: [Tutor] Can you create an image from Tkinter?
>
>Just wanted to let other people on the list know the results of how to save=
>=20
>a Tkinter canvas image.
>
>Magnus recommended looking at PIL, so I had another very careful read of=20
>the manual.
>Included in PIL is a module called ImageGrab which allows you to grab the=20
>entire screen (or a defined section of it), or to get images from the=20
>clipboard. This works only on Windows platforms.
>(Note that ImageGrab is part of the PIL package but is not a function of=
> Image)
>
>Also Fredrik Lundh was incredibly helpful in helping me sort out some=20
>problems and also forwarded a link to one of his posts on how to grab just=
>=20
>the Tkinter canvas:
>
>http://mail.python.org/pipermail/image-sig/2003-May/002292.html
>
>The code example in that post is as follows:
>
>the following script works on Windows (requires PIL 1.1.4):
>import sys
>import Tkinter
>import ImageGrab
>
>canvas =3D Tkinter.Canvas(width=3D600, height=3D400)
>canvas.create_line(0, 0, 600, 400, fill=3D"red", width=3D10)
>canvas.pack()
>
>canvas.update()
>
>if sys.platform =3D=3D "win32":
>
>         # get window location
>         x0 =3D canvas.winfo_rootx()
>         y0 =3D canvas.winfo_rooty()
>         x1 =3D x0 + canvas.winfo_width()
>         y1 =3D y0 + canvas.winfo_height()
>
>         im =3D ImageGrab.grab((x0, y0, x1, y1))
>
>else:
>
>         raise NotYetImplemented("oops!")
>
>im.show()
>
>Thanks again to everyone on the list for making this such an interesting=20
>place to get and exchange information.
>Thanks also to Fredrik Lundh for writing such great code and supporting it=
>=20
>so generously.
>
>Fred Milgrom
>
>
>At 09:14 PM 13/06/03 +0200, Magnus Lyck=E5 wrote:
>>At 11:48 2003-06-13 +1000, Alfred Milgrom wrote:
>>>I wonder if anyone can help me with creating savable images (say GIF or=20
>>>BMP) under Python?
>>
>>I think you should take a look at PIL:
>>http://www.pythonware.com/products/pil/index.htm#pil114
>>
>>A slightly old handbook is here:
>>http://www.pythonware.com/library/pil/handbook/index.htm
>>
>>
>>--
>>Magnus Lycka (It's really Lyck&aring;), magnus@thinkware.se
>>Thinkware AB, Sweden, www.thinkware.se
>>I code Python ~ The Agile Programming Language
>
>
>
>--__--__--
>
>Message: 2
>From: valhalla <tireseas@onetel.com>
>Reply-To: tireseas@onetel.com
>To: tutor@python.org
>Date: Thu, 19 Jun 2003 06:20:33 +0100
>Subject: [Tutor] Re: Using time module to count off seconds before an event
>
>Hello Michael Janssen & Magnus Lycka
>
>Thank you both for your help and suggestions. I'll play around with the i=
>deas=20
>and see what I can come up with. I didn't realise that this wouldn't be=20
>straight-forward. I thought that it might be a countdown that I could set=
> as=20
>a range (similar possibly to Michael's suggestion) on one of the time=20
>functions that when it would reach ctime + 60 seconds, a message could be=
>=20
>printed to the screen saying "Time's Up" or be cancelled if the player go=
>t=20
>the correct answer. May have to rethink the design a bit.
>
>I also didn't realise that my message got sent to the list twice - sorry =
>for=20
>the repeat!! Ooops :-(
>
>Andy
>
>--=20
>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>||  Reg. Linux User: 313143 ||
>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>Sign the Petition:
>http://www.PetitionOnline.com/endtcpa1/
>
>
>--__--__--
>
>Message: 3
>From: "Alan Gauld" <alan.gauld@blueyonder.co.uk>
>To: "Wari Wahab" <wari@home.wari.org>,
>    <tutor@python.org>,
>    "Bob Gailer" <bgailer@alum.rpi.edu>
>Subject: Re: [Tutor] why is list.pop(0) slow?
>Date: Thu, 19 Jun 2003 07:59:47 +0100
>
>> >I've been playing around with very large lists and found out by
>chance
>> >that pop(0) is 8 times slower than pop(). Is it really that bad?
>> >Performance improved when the list i have is reversed and used
>pop().
>
>How big are your lists? I just tried a 1 million member list and
>got no measurable difference between pop() and pop(0).
>
>Alan G.
>
>
>
>--__--__--
>
>Message: 4
>Date: Thu, 19 Jun 2003 10:39:38 +0200
>From: Gregor Lingl <glingl@aon.at>
>To:  tutor@python.org
>Subject: Re: [Tutor] why is list.pop(0) slow?
>
>
>
>Alan Gauld schrieb:
>
>>I've been playing around with very large lists and found out by
>>chance
>  
>>that pop(0) is 8 times slower than pop(). Is it really that bad?
>>Performance improved when the list i have is reversed and used
>>pop().
>>
>>How big are your lists? I just tried a 1 million member list and
>>got no measurable difference between pop() and pop(0).
>>  
>>
>
>Hi all!
>
>I tried this out and (invariably) found the following
>paradox result:
>
> >>> l=range(1000000)
> >>> if 1:
>...     for i in range(3):
>...         a=clock()
>...         l.pop()
>...         b=clock()
>...         l.pop(0)
>...         c=clock()
>...         print b-a
>...         print c-b
>...
>999999
>0
>0.101023984606
>0.059478771889
>999998
>1
>0.0128689504199
>0.0605054383992
>999997
>2
>0.0128781694661
>0.0593547338127
>
>which means: when done for the first time, pop() takes
>approximately twice as much time as pop(0) , whereas
>in all the following executions of the body of the loop
>pop() is approximately five times faster than pop(0).
>Notice that only the performance of pop() changes.
>
>Aha! ??? Let's try the converse:
>
> >>> l=range(1000000)
> >>> if 1:
>...     for i in range(3):
>...         a=clock()
>...         l.pop(0)
>...         b=clock()
>...         l.pop()
>...         c=clock()
>...         print b-a
>...         print c-b
>...
>0
>999999
>0.14588973015
>0.0120258267389
>1
>999998
>0.065228104346
>0.0120895219675
>2
>999997
>0.0598760289713
>0.0118950839017
>
>Hmmm. So the first call of the method pop is
>significantly slower than any following one. And
>pop() in fact five times faster than pop(0) with
>this 1000000-member-list
>
>(Done on a 400MHz-Windows 2000 Machine)
>
>Best wishes, Gregor
>
>
>
>
>
>
>
>
>--__--__--
>
>Message: 5
>From: "DAVID BABCOCK" <decibelshelp@charter.net>
>To: Tutor@python.org
>Date: Thu, 19 Jun 2003 04:38:28 -0400
>Subject: [Tutor] Printing std.out (terminal) with formatted output
>
>I am wanting to print some results from a database to the 
>user. Just using the terminal and std.out for right now.
>
>Is there any module that might give some help making the 
>output more readable. 
>
>Saw one called prettyprint that might fit the bill. Just 
>trying to not reinvent the wheel. I did a search on 
>google, not coming up with much do to common words like 
>format and print.
>
>Thanks,
>
>Dave
>
>
>--__--__--
>
>Message: 6
>To: tutor <tutor@python.org>
>From: Denis Dzyubenko <shad@mail.kubtelecom.ru>
>Date: Thu, 19 Jun 2003 13:27:07 +0400
>Subject: [Tutor] using select
>
>Hello, all python programmers!
>
>In my python-program I used poll() function, but I noticed that poll()
>is not accessible under Windows, so I changed this code:
>
>...
>POLL_TIMEOUT = 10
>...
>        fd = select.poll()
>        fd.register(sfdcl, select.POLLIN | select.POLLPRI)
>        while len(fd.poll(POLL_TIMEOUT)) > 0:
>            p = sfdcl.recvfrom(self.getmsgsize())
>...
>
>with this one:
>
>...
>        while len(select.select([sfdcl],[],[],POLL_TIMEOUT/1000.0)[0]) > 0:
>            p = sfdcl.recvfrom(self.getmsgsize())
>...
>
>It works just fine, but I have never worked with sockets (and
>select(),poll() functions), so I am not sure if this code is
>correct. Where can I read docs about sockets and select/poll (I have
>already read man pages) ?
>
>Then, my program must wait input from socket and from stdin, now I do
>this using select() that waits for data in two file descriptiors
>(sys.stdin and 'sfdcl' - my socket), but I noticed that windows
>doesn't support select() with file descriptors, only sockets are
>acceptable. What should I do? Can threads help me - for example one
>thread reads from stdin, and another - from socket ?
>
>Thanks for your help!
>
>-- 
>Denis.
>
>P.S. Sorry for terrible english, it is not my native language :(
>
>
>--__--__--
>
>Message: 7
>Date: Thu, 19 Jun 2003 11:43:31 +0200
>To: "R. Alan Monroe" <amonroe@columbus.rr.com>
>From: Magnus =?iso-8859-1?Q?Lyck=E5?= <magnus@thinkware.se>
>Subject: Re: [Tutor] crash when importing random or sys module, in my 
>  embedded python
>Cc: tutor@python.org
>
>At 22:30 2003-06-18 -0400, R. Alan Monroe wrote:
>>Yeah I just made a backup then commented out the _verify. It works now
>
>What if you change %g to %r instead, to show more decimals?
>What will the traceback message be then? If you really have
>the same output from 2*math.pi as I do, then _verify shouldn't
>complain. It certainly seems that something strange is going
>on here.
>
>
>--
>Magnus Lycka (It's really Lyck&aring;), magnus@thinkware.se
>Thinkware AB, Sweden, www.thinkware.se
>I code Python ~ The Agile Programming Language 
>
>
>