[Tutor] Tutor Digest, Vol 84, Issue 56

Daniel Otero djotero at plymouth.edu
Mon Feb 14 22:59:19 CET 2011



tutor-request at python.org wrote:

>Send Tutor mailing list submissions to
>	tutor at 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 at python.org
>
>You can reach the person managing the list at
>	tutor-owner at 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: How to run another python script? (Karim)
>   2. Re: How to run another python script? (Karim)
>   3. Re: Higher-Order Function Examples (Rafael Dur?n Casta?eda)
>   4. Re: Higher-Order Function Examples (Walter Prins)
>   5. Re: Higher-Order Function Examples (Rafael Dur?n Casta?eda)
>   6. Re: Higher-Order Function Examples (Walter Prins)
>   7. GUI + python program (Mitch Seymour)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Mon, 14 Feb 2011 17:04:16 +0100
>From: Karim <karim.liateni at free.fr>
>To: Dan Lee <allbory.dan at gmail.com>, python mail list
>	<tutor at python.org>
>Subject: Re: [Tutor] How to run another python script?
>Message-ID: <4D595280.8080809 at free.fr>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>On 02/14/2011 04:51 PM, Dan Lee wrote:
>> Hi.
>>
>> I just knew what python is.
>> Now I'm about to write backup script.Now I got 2 scripts.
>>
>> AAA : generate zip file
>> BBB : delete old file.
>>
>> AAA is done.
>> Now I'm going to code BBB file. and I will fix AAA to call BBB to
>> delete dump file at the end.
>
>One possibility:
>
>exec( "<PATH_TO_BBB>/BBB" )
>
>Or make import of BBB module as below:
>
>from BBB import main
>BBB.main()
>
>Regards
>Karim
>
>> Please let me know How can I call the BBB file from AAA file.
>>
>> Thanks in advance.
>> Dan
>
>
>
>------------------------------
>
>Message: 2
>Date: Mon, 14 Feb 2011 17:34:57 +0100
>From: Karim <karim.liateni at free.fr>
>To: Dan Lee <allbory.dan at gmail.com>, python mail list
>	<tutor at python.org>
>Subject: Re: [Tutor] How to run another python script?
>Message-ID: <4D5959B1.9040509 at free.fr>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>
>Better way is to not have BBB but simply to use Exception (pseudo-code):
>
>try:
><generate zip file>
>    ...
>catch IOError, e:
>     print("Error encountered in generating zip file:",  e)
>else:
>     import os
>     os.remove('<path_to_file>')
>
>Regards
>Karim
>
>
>On 02/14/2011 05:04 PM, Karim wrote:
>> On 02/14/2011 04:51 PM, Dan Lee wrote:
>>> Hi.
>>>
>>> I just knew what python is.
>>> Now I'm about to write backup script.Now I got 2 scripts.
>>>
>>> AAA : generate zip file
>>> BBB : delete old file.
>>>
>>> AAA is done.
>>> Now I'm going to code BBB file. and I will fix AAA to call BBB to
>>> delete dump file at the end.
>>
>> One possibility:
>>
>> exec( "<PATH_TO_BBB>/BBB" )
>>
>> Or make import of BBB module as below:
>>
>> from BBB import main
>> BBB.main()
>>
>> Regards
>> Karim
>>
>>> Please let me know How can I call the BBB file from AAA file.
>>>
>>> Thanks in advance.
>>> Dan
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>
>
>
>------------------------------
>
>Message: 3
>Date: Mon, 14 Feb 2011 20:16:02 +0100
>From: Rafael Dur?n Casta?eda 	<rafadurancastaneda at gmail.com>
>To: Tutor at python.org
>Subject: Re: [Tutor] Higher-Order Function Examples
>Message-ID:
>	<AANLkTi=0j=JUYEnRdG6UB1R74mPXxo7F6MGVjV4YufEi at mail.gmail.com>
>Content-Type: text/plain; charset="iso-8859-1"
>
>Could we consider sorted as an high order function?
>
>sorted_list = sorted(list_strings, key = str.lower)
>
>2011/2/14 Steven D'Aprano <steve at pearwood.info>
>
>> Steven D'Aprano wrote:
>>
>>  An example might help. Back in the old days, before Python had a sum()
>>> function, the easiest way to add up a list of numbers was to use reduce and
>>> a small function to add two numbers:
>>>
>>> def add(x, y):
>>>    return x+y
>>>
>>> total = filter(add, [2, 4, 5, 9, 1])
>>>
>>
>> Arggggh! Of course, I meant *reduce* in that example, not filter. Sorry for
>> any confusion!
>>
>>
>>
>>
>> --
>> Steven
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>-------------- next part --------------
>An HTML attachment was scrubbed...
>URL: <http://mail.python.org/pipermail/tutor/attachments/20110214/db194d56/attachment-0001.html>
>
>------------------------------
>
>Message: 4
>Date: Mon, 14 Feb 2011 22:06:34 +0200
>From: Walter Prins <wprins at gmail.com>
>To: Rafael Dur?n Casta?eda <rafadurancastaneda at gmail.com>
>Cc: Tutor at python.org
>Subject: Re: [Tutor] Higher-Order Function Examples
>Message-ID:
>	<AANLkTinJ5YyYRAc5iNiyXiCwhqz6oWrG_1Xmjd81Pi+6 at mail.gmail.com>
>Content-Type: text/plain; charset="iso-8859-1"
>
>2011/2/14 Rafael Dur?n Casta?eda <rafadurancastaneda at gmail.com>
>
>> Could we consider sorted as an high order function?
>>
>> sorted_list = sorted(list_strings, key = str.lower)
>>
>>
>No because sorted() returns a list as a result.   A higher order function
>produces another function as a result, or takes one or more functions as a
>parameter.
>
>Walter
>-------------- next part --------------
>An HTML attachment was scrubbed...
>URL: <http://mail.python.org/pipermail/tutor/attachments/20110214/441500fb/attachment-0001.html>
>
>------------------------------
>
>Message: 5
>Date: Mon, 14 Feb 2011 21:23:54 +0100
>From: Rafael Dur?n Casta?eda 	<rafadurancastaneda at gmail.com>
>To: Tutor at python.org
>Subject: Re: [Tutor] Higher-Order Function Examples
>Message-ID:
>	<AANLkTim22rxb=5=XnZO0QbTXzN8qt3A79T=Y9p+dn1c3 at mail.gmail.com>
>Content-Type: text/plain; charset="iso-8859-1"
>
>In the example I gave:
>
>sorted_list = sorted(list_strings, key = str.lower)
>
>sorted takes str.lower as a parameter, doesn't it? So, it should be a high
>order function
>
>El 14 de febrero de 2011 21:06, Walter Prins <wprins at gmail.com> escribi?:
>
>>
>>
>> 2011/2/14 Rafael Dur?n Casta?eda <rafadurancastaneda at gmail.com>
>>
>> Could we consider sorted as an high order function?
>>>
>>> sorted_list = sorted(list_strings, key = str.lower)
>>>
>>>
>> No because sorted() returns a list as a result.   A higher order function
>> produces another function as a result, or takes one or more functions as a
>> parameter.
>>
>> Walter
>>
>-------------- next part --------------
>An HTML attachment was scrubbed...
>URL: <http://mail.python.org/pipermail/tutor/attachments/20110214/cf8b2ffb/attachment-0001.html>
>
>------------------------------
>
>Message: 6
>Date: Mon, 14 Feb 2011 22:35:02 +0200
>From: Walter Prins <wprins at gmail.com>
>To: Rafael Dur?n Casta?eda <rafadurancastaneda at gmail.com>
>Cc: Tutor at python.org
>Subject: Re: [Tutor] Higher-Order Function Examples
>Message-ID:
>	<AANLkTin+4cO9Y=2HYTcXmbxk8EBERTcxXK04bmYH+CjE at mail.gmail.com>
>Content-Type: text/plain; charset="iso-8859-1"
>
>2011/2/14 Rafael Dur?n Casta?eda <rafadurancastaneda at gmail.com>
>
>> In the example I gave:
>>
>>
>> sorted_list = sorted(list_strings, key = str.lower)
>>
>> sorted takes str.lower as a parameter, doesn't it? So, it should be a high
>> order function
>>
>
>My apologies! Yes, you are of course quite correct!  :)
>
>Walter
>-------------- next part --------------
>An HTML attachment was scrubbed...
>URL: <http://mail.python.org/pipermail/tutor/attachments/20110214/ddefa6fe/attachment-0001.html>
>
>------------------------------
>
>Message: 7
>Date: Mon, 14 Feb 2011 14:55:36 -0500
>From: Mitch Seymour <mitchseymour at gmail.com>
>To: tutor at python.org
>Subject: [Tutor] GUI + python program
>Message-ID:
>	<AANLkTi=MQwXnC1_-7bxXTX9Ou+LUGhWM2G=EEiQx7zbP at mail.gmail.com>
>Content-Type: text/plain; charset="iso-8859-1"
>
>Hello,
>
>I am trying to design a program and GUI that will allow the user to select
>from a series of options and, depending on which options are selected in the
>GUI, information will then be placed in a html or pdf template.
>
>Here's an example.
>
>Option A
>Option B
>Option C
>
>If Option A, insert _____ into the template.
>If Option B, insert _____ into the template.
>If Option C, insert _____ into the template.
>
>The reason I used ______ is because the user needs to be able to edit, from
>the GUI, which information is associated with each option, and,
>subsequently, which information will be placed into the template.
>
>However, I am very new to python and I don't how to do this. A friend
>suggested that I create a python file that would store the user defined
>information, which would be read by the program before the information is
>placed into the template. So the user could select the options from the GUI,
>edit the associated information from a preferences tab, and then initiate
>the process of placing the info into the templates.
>
>My question is, how would you do this and, if I do create a file to store
>the information, could you please give me some examples of code to get me
>started?
>
>Thanks so much!
>-------------- next part --------------
>An HTML attachment was scrubbed...
>URL: <http://mail.python.org/pipermail/tutor/attachments/20110214/cd9c6a8c/attachment.html>
>
>------------------------------
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>End of Tutor Digest, Vol 84, Issue 56
>*************************************


More information about the Tutor mailing list