[Tutor] help

Pablo Manzanera chikitychina@home.com
Sun, 26 Aug 2001 19:58:12 -0400


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. Making my program an executable/distributable (paul)
>    2. Re: map & lambda to create dictionary from lists? (Reisfeld, Brad             CAR)
>    3. Re: time question (Lloyd Hugh Allen)
> 
> --__--__--
> 
> Message: 1
> From: "paul" <clanoftheinsane@hotmail.com>
> To: <tutor@python.org>
> Date: Fri, 24 Aug 2001 18:12:26 -0400
> Subject: [Tutor] Making my program an executable/distributable
> 
> This is a multi-part message in MIME format.
> 
> ------=_NextPart_000_0009_01C12CC8.548A0FA0
> Content-Type: text/plain;
>         charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> 
> Hello all,
> i have asked this question before, about a week or so ago, but i just =
> want to re-ask it in case anyone missed it.  i have written a python =
> program including Tkinter, and when i used py2exe to convert it to an =
> executable, it called for the riscosenviron, riscos, riscospath, and ce =
> modules.  is this because of my using Tkinter in my script?  does py2exe =
> not support Tkinter?  i'm just curious.  i finally finished my program, =
> and i just want to be able to distribute it.  please help?!?!
> 
> thanks a lot,
> paul brown
> 
> ------=_NextPart_000_0009_01C12CC8.548A0FA0
> Content-Type: text/html;
>         charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META content=3D"text/html; charset=3Diso-8859-1" =
> http-equiv=3DContent-Type>
> <META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
> <STYLE></STYLE>
> </HEAD>
> <BODY bgColor=3D#ffffff>
> <DIV><FONT face=3DArial size=3D2>Hello all,</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>i have asked this question before, =
> about a week or=20
> so ago, but i just want to re-ask it in case anyone missed it.&nbsp; i =
> have=20
> written a python program including Tkinter, and when i used py2exe to =
> convert it=20
> to an executable, it called for the riscosenviron, riscos, riscospath, =
> and ce=20
> modules.&nbsp; is this because of my using Tkinter in my script?&nbsp; =
> does=20
> py2exe not support Tkinter?&nbsp; i'm just curious.&nbsp; i finally =
> finished my=20
> program, and i just want to be able to distribute it.&nbsp; please=20
> help?!?!</FONT></DIV>
> <DIV>&nbsp;</DIV>
> <DIV><FONT face=3DArial size=3D2>thanks a lot,</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>paul brown</FONT></DIV></BODY></HTML>
> 
> ------=_NextPart_000_0009_01C12CC8.548A0FA0--
> 
> --__--__--
> 
> Message: 2
> From: "Reisfeld, Brad             CAR" <Brad.Reisfeld@carrier.utc.com>
> To: "'tutor@python.org'" <tutor@python.org>
> Subject: Re: [Tutor] map & lambda to create dictionary from lists?
> Date: Sat, 25 Aug 2001 07:30:01 -0400
> 
> Hi,
> My preferred method for accomplishing this is quite simple:
> 
> >>> d={}
> >>> keys = ('name', 'age', 'food')
> >>> values = ('Monty', 42, 'spam')
> >>> map(d.setdefault, keys, values)
> ['Monty', 42, 'spam']
> >>> d
> {'name': 'Monty', 'age': 42, 'food': 'spam'}
> 
> -Brad
> 
> =================================
> 
> What I've got are two sequences.  The first is a sequence of strings
> that I want to use as the keys of a dictionary.  The second is a
> sequence of objects (strings, numbers, whatever) that I want to use as
> the values in the dictionary.  Of course, the two sequences have a
> one-to-one correspondence.
> 
> Here's what I've come up with using map and lambda so far and I want to
> know if it's Good:
> 
>     Python 2.0 (#1, Jan  8 2001, 10:18:58)
>     [GCC egcs-2.91.66 19990314 (egcs-1.1.2 release)] on sunos5
>     Type "copyright", "credits" or "license" for more information.
>     >>> d = {}
>     >>> keys = ('name', 'age', 'food')
>     >>> values = ('Monty', 42, 'spam')
>     >>> junk = map(lambda k, v: d.update({k: v}), keys, values)
>     >>> junk
>     [None, None, None]
>     >>> d
>     {'name': 'Monty', 'age': 42, 'food': 'spam'}
> 
> --__--__--
> 
> Message: 3
> Date: Sat, 25 Aug 2001 10:40:05 -0400
> From: Lloyd Hugh Allen <vze2f978@verizon.net>
> Reply-To: lha2@columbia.edu
> To: tutor@python.org
> Subject: Re: [Tutor] time question
> 
> Here's something strange:
> 
> ----code follows----
> >>> quitTime = (2001, 8, 22, 9, 45, -1, -1, -1, -1)
> >>> import time
> >>> nowTime = time.localtime(time.time())
> >>> nowTime
> (2001, 8, 25, 10, 0, 54, 5, 237, 1)
> >>> theDiff = []
> >>> for foo in range(len(nowTime)):
>         theDiff.append(nowTime[foo]-quitTime[foo])
> 
> 
> >>> theDiff
> [0, 0, 3, 1, -45, 55, 6, 238, 2]
> >>> theDiff = tuple(theDiff)
> >>> theDiff
> (0, 0, 3, 1, -45, 55, 6, 238, 2)
> >>> time.localtime(time.mktime(theDiff))
> (1999, 12, 2, 23, 15, 55, 3, 336, 0)
> ----end code-------
> 
> I had been hoping that time.mktime and time.localtime would
> intelligently handle the -45 minutes. Seems not to be the case. I trust
> that with well-formed times they are in fact inverse functions?
> 
> Here's my go at a real solution:
> -----code starts----
> >>> def convertTime(theDiff):
>         """Returns a time tuple with strictly positive elements.
> 
>         Note that this function does not intelligently handle months,
>         but assumes that all months are 28 days long."""
>         offSet = [0, 12, 28, 24, 60]
>         theDiff = list(theDiff)
>         for foo in range(len(theDiff)-1, 0, -1):
>                 if theDiff[foo]<0:
>                         theDiff[foo] = theDiff[foo] + offSet[foo]
>                         theDiff[foo-1] = theDiff[foo-1] - 1
>         theDiff = tuple(theDiff)
>         return theDiff
> ----end code--------
> 
> -LHA
> 
> --__--__--
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> End of Tutor Digest