[Tutor] ANN: pythonpackages.com beta

2012-07-30 Thread Alex Clark
Hi Python Tutor folks, I am reaching out to various Python-related programming communities in order to offer new help packaging your software. If you have ever struggled with packaging and releasing Python software (e.g. to PyPI), please check out this service: - http://pythonpackages.com T

Re: [Tutor] finally without try or except

2012-07-30 Thread Steven D'Aprano
Tino Dai wrote: I just remember that there was a performance hit or something for doing that. Does that sound familiar to anyone? Yes, and no. Creating a try block in Python is lightweight and fast. It is about as fast as the "pass" statement, that is, pretty damn fast and more or less faste

Re: [Tutor] finally without try or except

2012-07-30 Thread Steven D'Aprano
Tino Dai wrote: Yes, but that would involve surrounding the entire method with a try except finally block. I was told by the Python-Guru-In Residence that shouldn't emulate Java code in Python, and that was generally bad programming practice (no flame war intended) And that is correct. It is *

Re: [Tutor] Help please!

2012-07-30 Thread Prasad, Ramit
> Hello all! I have a very simple question but I'm very new to python. Could you > describe to me what the following piece of Python code says in English > please? Welcome to the list and Python! When posting code in the future I recommend posting in plain text and not "rich" text or HTML. If you

Re: [Tutor] Help please!

2012-07-30 Thread Emile van Sebille
On 7/30/2012 12:52 PM Victoria Homsy said... Hello all! I have a very simple question but I'm very new to python. Could you describe to me what the following piece of Python code says in English please? def print_a_line(line_count, f): print line_count, f.readline() This function accepts

[Tutor] sqlite3 Dilemma

2012-07-30 Thread Khalid Al-Ghamdi
Damn! So its so serious they have a name for it! No wonder I was stumped ... Any way thanks you guys have been super helpful. بتاريخ الاثنين، ٣٠ يوليو، ٢٠١٢، جاء من Peter Otten __pete...@web.de : > Khalid Al-Ghamdi wrote: > > > I am a teacher at an industrial training center. We have to conduct

Re: [Tutor] finally without try or except

2012-07-30 Thread eryksun
On Mon, Jul 30, 2012 at 3:10 PM, Tino Dai wrote: > On Mon, Jul 30, 2012 at 1:52 PM, Mark Lawrence > wrote: > >> Sorry I'm not completely sure what you're asking for but will this help >> http://docs.python.org/library/atexit.html ? >> > I think this might be what I'm looking for. But for about 2

[Tutor] Help please!

2012-07-30 Thread Victoria Homsy
Hello all! I have a very simple question but I'm very new to python. Could you describe to me what the following piece of Python code says in English please?  def print_a_line(line_count, f): print line_count, f.readline() I understand that line_count counts the number of lines in the Python pro

Re: [Tutor] finally without try or except

2012-07-30 Thread Tino Dai
On Mon, Jul 30, 2012 at 3:35 PM, Brett Ritter wrote: > On Mon, Jul 30, 2012 at 12:20 PM, Tino Dai wrote: > > Yes, but that would involve surrounding the entire method with a try > except > > finally block. I was > > told by the Python-Guru-In Residence that shouldn't emulate Java code in > > Pyt

Re: [Tutor] finally without try or except

2012-07-30 Thread Brett Ritter
On Mon, Jul 30, 2012 at 12:20 PM, Tino Dai wrote: > Yes, but that would involve surrounding the entire method with a try except > finally block. I was > told by the Python-Guru-In Residence that shouldn't emulate Java code in > Python, and that was > generally bad programming practice (no flame wa

Re: [Tutor] finally without try or except

2012-07-30 Thread Steve Willoughby
On 30-Jul-12 10:52, Mark Lawrence wrote: On 30/07/2012 17:56, Tino Dai wrote: Is there anyway to execute a block of code at the end of a program in 2.6 regardless of what happened before eg exiting normally or died because of an exception? Sorry I'm not completely sure what you're askin

Re: [Tutor] finally without try or except

2012-07-30 Thread Alan Gauld
On 30/07/12 17:56, Tino Dai wrote: Is there anyway to execute a block of code at the end of a program in 2.6 regardless of what happened before eg exiting normally or died because of an exception? Yes, try/finally. That's what it's there for. I was thinking about maybe a free standing

Re: [Tutor] finally without try or except

2012-07-30 Thread Tino Dai
On Mon, Jul 30, 2012 at 1:44 PM, Prasad, Ramit wrote: > > Actually, what I'm doing is keeping a pending item log in memory as an > array > > and then saving it to the DB at the end of the program, but what happens > if > > the user hits ctrl-c, then the pending items array is lost. That's the > us

Re: [Tutor] finally without try or except

2012-07-30 Thread Tino Dai
On Mon, Jul 30, 2012 at 2:44 PM, Albert-Jan Roskam wrote: > *From:* Tino Dai > > *To:* nz*tutor pythonzzz > *Sent:* Monday, July 30, 2012 6:56 PM > *Subject:* [Tutor] finally without try or except > > Hi! > > Is there anyway to execute a block of code at the end of a program in > 2.6 regar

Re: [Tutor] finally without try or except

2012-07-30 Thread Tino Dai
On Mon, Jul 30, 2012 at 1:52 PM, Mark Lawrence wrote: > On 30/07/2012 17:56, Tino Dai wrote: > >> Hi! >> >> Is there anyway to execute a block of code at the end of a program >> in >> 2.6 regardless of what happened before eg exiting normally or died because >> of an exception? >> I was thin

Re: [Tutor] finally without try or except

2012-07-30 Thread Albert-Jan Roskam
From: Tino Dai To: nz*tutor pythonzzz >Sent: Monday, July 30, 2012 6:56 PM >Subject: [Tutor] finally without try or except > > >Hi! > > >     Is there anyway to execute a block of code at the end of a program in 2.6 >regardless of what happened before eg exiting normally or died because of an

Re: [Tutor] sqlite3 Dilemma

2012-07-30 Thread Peter Otten
Khalid Al-Ghamdi wrote: > I am a teacher at an industrial training center. We have to conduct > hands-on exams (fixing pumps, etc). I review all the test schedules for > all the students (made by other teachers) to make sure there are no > clashes due to lack of ample supply of equipment or tools.

Re: [Tutor] finally without try or except

2012-07-30 Thread Mark Lawrence
On 30/07/2012 17:56, Tino Dai wrote: Hi! Is there anyway to execute a block of code at the end of a program in 2.6 regardless of what happened before eg exiting normally or died because of an exception? I was thinking about maybe a free standing finally code block or a decorator. Any hint

Re: [Tutor] finally without try or except

2012-07-30 Thread Prasad, Ramit
> Actually, what I'm doing is keeping a pending item log in memory as an array > and then saving it to the DB at the end of the program, but what happens if > the user hits ctrl-c, then the pending items array is lost. That's the use > case that I'm looking for a solution to. http://docs.python.or

Re: [Tutor] finally without try or except

2012-07-30 Thread Tino Dai
On Mon, Jul 30, 2012 at 1:16 PM, Marc Tompkins wrote: > On Mon, Jul 30, 2012 at 9:56 AM, Tino Dai wrote: > >> Hi! >> >> Is there anyway to execute a block of code at the end of a program >> in 2.6 regardless of what happened before eg exiting normally or died >> because of an exception? >> I

Re: [Tutor] finally without try or except

2012-07-30 Thread Marc Tompkins
On Mon, Jul 30, 2012 at 9:56 AM, Tino Dai wrote: > Hi! > > Is there anyway to execute a block of code at the end of a program in > 2.6 regardless of what happened before eg exiting normally or died because > of an exception? > I was thinking about maybe a free standing finally code block or

[Tutor] finally without try or except

2012-07-30 Thread Tino Dai
Hi! Is there anyway to execute a block of code at the end of a program in 2.6 regardless of what happened before eg exiting normally or died because of an exception? I was thinking about maybe a free standing finally code block or a decorator. Any hints? Tino

Re: [Tutor] sqlite3 Dilemma

2012-07-30 Thread Khalid Al-Ghamdi
Thanks for your input Walter. Are there any techniques to achieve this via code or sql you share. Because I was thinking along the same you mentioned but didnt knwo how to go about it. بتاريخ الاثنين، ٣٠ يوليو، ٢٠١٢، جاء من Walter Prins wpr...@gmail.com: > On 30 July 2012 14:57, Khalid Al-Ghamdi

Re: [Tutor] Help please!

2012-07-30 Thread Puneeth Chaganti
On Mon, Jul 30, 2012 at 9:35 PM, Victoria Homsy wrote: > Hi! I am a new Python user, and would really appreciate some help. My code > is as follows: > > from sys import argvs > script, mum_mood, dad_mood = argvs > > # my own function > def dad_and_mum_mood(mum_mood, dad_mood): > print "If both mum

[Tutor] Help please!

2012-07-30 Thread Victoria Homsy
Hi! I am a new Python user, and would really appreciate some help. My code is as follows: from sys import argvs script, mum_mood, dad_mood = argvs # my own function def dad_and_mum_mood(mum_mood, dad_mood): print "If both mum and dad are in a good mood, all is good." print "If one is and one isn

Re: [Tutor] sqlite3 Dilemma

2012-07-30 Thread Walter Prins
On 30 July 2012 14:57, Khalid Al-Ghamdi wrote: > Hi All, > > I am a teacher at an industrial training center. We have to conduct hands-on > exams (fixing pumps, etc). I review all the test schedules for all the > students (made by other teachers) to make sure there are no clashes due to > lack of

[Tutor] sqlite3 Dilemma

2012-07-30 Thread Khalid Al-Ghamdi
Hi All, I am a teacher at an industrial training center. We have to conduct hands-on exams (fixing pumps, etc). I review all the test schedules for all the students (made by other teachers) to make sure there are no clashes due to lack of ample supply of equipment or tools. Meaning no two trainees