On 29/01/18 00:45, Alan Gauld via Tutor wrote:
> scores = [] # three sets of scores.
Oops, sorry that line shouldn't be there.
It came from my first pass through the code,
before I saw how you were storing the data lower down.
--
Alan G
Author of the Learn to Program web site
http://www.alan-
On 28/01/18 22:06, Edna Broukhim wrote:
You have tried to give the variables sensible names but
a little bit more work will make your code more readable
and therefore easier to debug. You need to rethink your
data model slightly.
You have a number of users (which you don't explicitly
store at pr
On 02/07/17 11:03, Richard Grose wrote:
> https://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwiw1tD3qurUAhULKlAKHWMOAPMQFggkMAA&url=https%3A%2F%2Fgithub.com%2FCWade3051%2FPy%2Ftree%2Fmaster%2FAbsolute%2520Book%2Fpy3e_source&usg=AFQjCNG36WhZfh5ftqWncjtgZy3z6xgh6g&cad=rjt
>
https://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwiw1tD3qurUAhULKlAKHWMOAPMQFggkMAA&url=https%3A%2F%2Fgithub.com%2FCWade3051%2FPy%2Ftree%2Fmaster%2FAbsolute%2520Book%2Fpy3e_source&usg=AFQjCNG36WhZfh5ftqWncjtgZy3z6xgh6g&cad=rjt
Py/Absolute Book/py3e_source at master · CW
On 24/07/2016 16:38, Ken G. wrote:
While the following program prints out fine using
Python 2.7.6 in Ubuntu 14.04.4 as developed using
Geany 1.23.1, same program won't print out to printer
under Windows 10 Pro (64 bit). Geany uses there is
version 1.28 using Python 2.7.12. I can use CTRL-P
t
On Sun, Jul 24, 2016 at 11:38:06AM -0400, Ken G. wrote:
> While the following program prints out fine using
> Python 2.7.6 in Ubuntu 14.04.4 as developed using
> Geany 1.23.1, same program won't print out to printer
> under Windows 10 Pro (64 bit). Geany uses there is
> version 1.28 using Python 2.
On 12/03/16 05:15, DiliupG wrote:
> All the help and guidance you need are in the pages here.
>
> http://programarcadegames.com/
>
> if you follow the book slowly from the start you shouldn't have a problem.
> If you do, stackoverflow is a good place to ask.
As is the tutor list of course. :-)
All the help and guidance you need are in the pages here.
http://programarcadegames.com/
if you follow the book slowly from the start you shouldn't have a problem.
If you do, stackoverflow is a good place to ask.
When ever you ask a question try to give as much details as possible so
that who eve
On 11/03/16 15:11, Ethan Batterman wrote:
> I am really struggling with Lab 9: Functions pt 3 and 4 of program arcade
> games.
We have no idea what you are talking about.
I assume you are studying some kind of course or book. But which one?
What is Lab 9? What are functions pt 3 and 4?
What is pr
On 16/12/14 04:06, Sunil Bharuchi wrote:
I went to the website (www.courseptr.com/downloads) to download the source
code (py3e_source.zip). It's not there. Where can I get it the source code?
Try using Google with
python absolute beginners source code
--
Alan G
Author of the Learn to Program
I went to the website (www.courseptr.com/downloads) to download the source
code (py3e_source.zip). It's not there. Where can I get it the source code?
--
Sunil Bharuchi
sunilkumar.bharuchi@mail.mil
sbharu...@gmail.com
(C) 408.644.7626
___
Tutor mail
On Mon, Oct 8, 2012 at 11:55 AM, Tharuni Dheeraj
wrote:
> please send me the program for the following que:
>
> Write a program that asks the user for a dollar amount.It then reports the
> corresponding number of euros by using the current exchange rate.
> --
> Regards,
> Tharuni Dheeraj
>
>
> ___
On 10/8/2012 11:55 AM, Tharuni Dheeraj wrote:
please send me the program for the following que:
Write a program that asks the user for a dollar amount.It then reports
the corresponding number of euros by using the current exchange rate.
As the list name (Tutor) suggests we are here to help yo
On 08/10/2012 16:55, Tharuni Dheeraj wrote:
please send me the program for the following que:
Write a program that asks the user for a dollar amount.It then reports the
corresponding number of euros by using the current exchange rate.
--
Regards,
Tharuni Dheeraj
__
On 07/07/2012 09:34, Alan Gauld wrote:
On 07/07/12 04:35, Steven D'Aprano wrote:
I find it ironic that you are suggesting removing the debugger to make
it easier to debug the code :)
But the pdb.trace() calls are not needed for debugging. The
interactive debugger will work just fine without t
On 07/07/12 04:35, Steven D'Aprano wrote:
I find it ironic that you are suggesting removing the debugger to make
it easier to debug the code :)
But the pdb.trace() calls are not needed for debugging. The
interactive debugger will work just fine without them.
They are for very specialised use.
Prasad, Ramit wrote:
I believe that the usage of 'in ' converts it into a set (or
set-like) object so probably that is the same as set(list(set())).
No, certainly not. That would be terribly inefficient, since it means first
iterating over blah entirely to convert it into a set, and then iter
Ali Torkamani wrote:
I could resolve it by defining a small function:
def getValue(mydict,keys):
A=[];
for i in keys:
A=A+[mydict[i]]
return A
That will be terribly, painfully inefficient for large amounts of data. Do you
understand Big O notation? The above is O(N**2), c
Alan Gauld wrote:
On 06/07/12 22:16, Ali Torkamani wrote:
have the pdb.set_trace()'s for debugging, to see what's going on inside.
So what does it show?
If you aren't using it get rid of it. The less distractions there are
the easier it is to debug things.
I find it ironic that you are s
Ali Torkamani wrote:
Dear Tutors,
I'm trying to write a dictionary into a csv file, in the following code
FlatData is the global dictionary whose keys are datetime objects, and the
values are list of dictionaries. sCommonFeatures are key's that exist in
all of such 'sub'-dictionaries, and sOtherF
On 06/07/12 22:16, Ali Torkamani wrote:
Actually printing some thing after that line does not show any thing,
OK, But it could be any of the lines above the print.
Why are you so sure its that line? You are probably correct but I'd like
to know why you are so sure? What have you done to isolat
> > Also what are you using the pdb traces for?
> > Do they show any output?
> Actually printing some thing after that line does not show any thing, I have
> the pdb.set_trace()'s for debugging, to see what's going on inside. ho would
> you debug that?
When debugging, I usually just add more pri
Please stop top posting, you have been asked at least once before, no
further comments, TIA.
On 06/07/2012 22:16, Ali Torkamani wrote:
Actually printing some thing after that line does not show any thing, I
have the pdb.set_trace()'s for debugging, to see what's going on inside. ho
would you de
Actually printing some thing after that line does not show any thing, I
have the pdb.set_trace()'s for debugging, to see what's going on inside. ho
would you debug that?
On Fri, Jul 6, 2012 at 3:57 PM, Alan Gauld wrote:
> On 06/07/12 18:21, Ali Torkamani wrote:
>
>> I'm using Python 2.7.
>> By st
On 06/07/12 18:21, Ali Torkamani wrote:
I'm using Python 2.7.
By stuck I mean, does not pass that specific line (but no errors).
How do you know that is the line it is stuck on?
def WriteOneDayToCSV(sCommonFeatures,sOtherFeatures,date):
FD=FlatData[date]
A=['UniqeDate','Year','Month','Da
I'm using Python 2.7.
By stuck I mean, does not pass that specific line (but no errors).
Like I said FD is a list of dictionaries. and sCommonFeatures are a subset
of key's that have value in all of the dictionaries.
On Fri, Jul 6, 2012 at 1:04 PM, Prasad, Ramit wrote:
> > > I could resolve it
> > I could resolve it by defining a small function:
> >
> > def getValue(mydict,keys):
> > A=[];
> > for i in keys:
> > A=A+[mydict[i]]
> > return A
> >
> > and then calling it: D=getValue(prog,sCommonFeatures);
> > (instead of D=[prog[key1] for key1 in list(sCommonFeatures)];)
Please do not top post.
>
> BTW I changed it to:
> D=[prog[key1] for key1 in list(sCommonFeatures)]
>
> because sCommonFeatures is actually a set, but it still has the smae problem
> On Fri, Jul 6, 2012 at 12:27 PM, Ali Torkamani wrote:
> Thanks, I checked, FD is not empty,
> Thanks for remind
I could resolve it by defining a small function:
def getValue(mydict,keys):
A=[];
for i in keys:
A=A+[mydict[i]]
return A
and then calling it: D=getValue(prog,sCommonFeatures);
(instead of D=[prog[key1] for key1 in list(sCommonFeatures)];)
but I'm still surprised why the latt
BTW I changed it to:
D=[prog[key1] for key1 in list(sCommonFeatures)]
because sCommonFeatures is actually a set, but it still has the smae problem
On Fri, Jul 6, 2012 at 12:27 PM, Ali Torkamani wrote:
> Thanks, I checked, FD is not empty,
> Thanks for reminding about the flush and close, but I
Thanks, I checked, FD is not empty,
Thanks for reminding about the flush and close, but I think some thing is
wrong with:
D=[prog[key1] for key1 in sCommonFeatures]
In the debug mode it works fine from the command line, but in the for loop
it gets stuck.
Ali
On Fri, Jul 6, 2012 at 12:22 PM, Pra
From: Ali Torkamani
> I'm trying to write a dictionary into a csv file, in the following code
> FlatData is the global dictionary whose keys are datetime objects, and the
> values are list of dictionaries. sCommonFeatures are key's that exist in all
> of such 'sub'-dictionaries, and sOtherFeatures
On Mon, Aug 29, 2011 at 00:19, TheIrda wrote:
> on the left check the Programming, networking and security and look for your
> book.
> Click download and you can see the link to the source code and book related
> software
>
> http://www.delmarlearning.com/companions/content/1435455002/downloads/in
On 07/16/2011 07:21 PM, Christopher King wrote:
Actually maybe not, depending on the complexity of the pattern, but it would
be difficult. You would have to know how much it decreases for every time
you go down or to the right.
If its more complex than that, you may have to program each rule in,
Actually maybe not, depending on the complexity of the pattern, but it would
be difficult. You would have to know how much it decreases for every time
you go down or to the right.
If its more complex than that, you may have to program each rule in, not
just enter them in a prompt. I'm assuming none
On 07/16/2011 05:32 PM, B G wrote:
Thanks, Emile-- although I'm not sure I was completely clear about my
objective. What I really meant is that is there a way (via machine learning)
to give the computer a list of rules and exceptions, and then have it
predict based on these rules the ionization e
Thanks, Emile-- although I'm not sure I was completely clear about my
objective. What I really meant is that is there a way (via machine learning)
to give the computer a list of rules and exceptions, and then have it
predict based on these rules the ionization energy. Ultimately I'm pretty
interest
On 7/16/2011 9:24 AM B G said...
I was just wondering how feasible it would be to build something like
the following:
Brief background, in chemistry, the ionization energy is defined as the
energy required to remove an electron from an atom. The ionization
energies of different elements follow g
On Thu, May 19, 2011 at 7:23 PM, Johnson Tran wrote:
> So I figured out how to use the loop method, thanks. I still cannot seem to
> figure out how to use Len() to show the output of my answers (from all my
> googling Len() seems to be used to count characters?) Also, I am not really
> sure I u
So I figured out how to use the loop method, thanks. I still cannot seem to
figure out how to use Len() to show the output of my answers (from all my
googling Len() seems to be used to count characters?) Also, I am not really
sure I understand how to use the append method of the list.
Here's my
"Johnson Tran" wrote
I had a couple questions about my program:
def CollectNames():
answer_set=set([])
sorted_list = sorted(answer_set)
This creates an empty set then sorts it and stores
the result as an empty list. I'm not sure what you
think it does but I'm guessing that's not it...
On Wed, May 18, 2011 at 7:26 AM, Johnson Tran wrote:
> Hi Again All,
>
> I had a couple questions about my program:
>
Corey gave you some good pointers already, but let me add a few...
>
> def CollectNames():
>
>answer_set=set([])
>sorted_list = sorted(answer_set)
>
This won't do what
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 05/18/2011 09:05 AM, Johnson Tran wrote:
> Thanks for the reply.
>
> So to append a word is it suppose to look kind of like:
>
> word=raw_input("Name #1: ")
> word.append(words)
>
> I keep getting error message:
>
> Traceback (most recent ca
Thanks for the reply.
So to append a word is it suppose to look kind of like:
word=raw_input("Name #1: ")
word.append(words)
I keep getting error message:
Traceback (most recent call last):
File "/Users/JT/Desktop/pythonfinal", line 23, in
CollectNames()
File "/Users/JT/Desktop/pyt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 05/18/2011 08:26 AM, Johnson Tran wrote:
> Hi Again All,
>
> I had a couple questions about my program:
>
> def CollectNames():
>
> answer_set=set([])
> sorted_list = sorted(answer_set)
> word=raw_input("Name #1: ")
>
> word=
"Patty" wrote
then I went through Alan Gauld's tutorial which also helped.
Glad to hear it :-)
If I just can't figure out how to do this with Tkinter and the
Python
I can send some basic code if that would help...
Imaging Library, is 'wxPython' the additional software I would want
to
Not wanting to hijack Terry's conversation, but for what it's worth:
On 16 November 2010 18:08, Patty wrote:
> If I just can't figure out how to do this with Tkinter and the Python
> Imaging Library, is 'wxPython' the additional software I would want to
> install and try with? Is its purpose to
tandards for this language?
Regards,
Patty
- Original Message -
From: "Terry Carroll"
To:
Sent: Monday, November 15, 2010 11:37 PM
Subject: Re: [Tutor] program hangs in while loop using wx.yield
On Sun, 14 Nov 2010, Alex Hall wrote:
Is there a basic tutorial for this
On Sun, 14 Nov 2010, Alex Hall wrote:
Is there a basic tutorial for this sort of thing?
Chapter 3 ("Working in an event-driven environment") of the book "wxPython
in Action" is a pretty good tutorial on event-driven GUI programming in
wxPython. The book in general is pretty good; I no longe
"Alex Hall" wrote
Is there a basic tutorial for this sort of thing?
There are a few books on the suvbject but I can't thik of
any titles off the top of my head. And mostly they are
written for C++ rather than Python.
fraction of a second. However, I need to wait for as long as the
human
ta
On 15 November 2010 00:12, Alex Hall wrote:
> Again: is there a basic tutorial that would explain how control works
> when dealing with a gui, especially one that is meant to last a long
> time but occasionally block input?
>
Normally the way is for the GUI controls (e.g. widgets, grids, objects
On 11/14/10, Alan Gauld wrote:
> "Alex Hall" wrote
>
>> The problem is that I want to go until there is a winner. You are
>> right about just letting the mainloop of the gui handle input (I
>> forgot the gui is already looping and waiting for input) but I would
>> like to make the user pause whil
"Alex Hall" wrote
The problem is that I want to go until there is a winner. You are
right about just letting the mainloop of the gui handle input (I
forgot the gui is already looping and waiting for input) but I would
like to make the user pause while the computer goes, this way the
user
cann
On 11/14/10, Alan Gauld wrote:
> "Alex Hall" wrote
>
>> I had this working back in the summer, but have since had to
>> restructure some things in the code. Now, my program is hanging
>> while
>> it waits for the human player to take his/her turn, and I am not
>> sure
>> how to free it;
>
> I don
"Alex Hall" wrote
I had this working back in the summer, but have since had to
restructure some things in the code. Now, my program is hanging
while
it waits for the human player to take his/her turn, and I am not
sure
how to free it;
I don't really understand this concept in a GUI?
Why wo
On Tue, Aug 4, 2009 at 3:01 PM, Chris
Fuller wrote:
> On Tuesday 04 August 2009 12:43, Megan Land wrote:
>> If at all possible I need a program that will work on Windows and Linux (I
>> know a tall order). I'm trying to keep this simple but if I have to use
>> two different programs I will.
> If
On Tuesday 04 August 2009 12:43, Megan Land wrote:
> Hi,
>
> I'm working on a python script to automate a program we run at work. The
> program is run from one command. The only problem is that it asks you to
> hit enter to continue after it runs. Is there a way I can do this?
>
> If at all poss
On Tue, Aug 4, 2009 at 12:43 PM, Megan Land wrote:
> Hi,
>
> I'm working on a python script to automate a program we run at work. The
> program is run from one command. The only problem is that it asks you to hit
> enter to continue after it runs. Is there a way I can do this?
>
> If at all poss
"Megan Land" wrote
I'm working on a python script to automate a program we run at work. The
program is run from one command. The only problem is that it asks you to
hit enter to continue after it runs. Is there a way I can do this?
Assuming it is using stdin/out to read the keystrokes yo
On Thu, Jun 18, 2009 at 10:37 AM, Jojo Mwebaze wrote:
> Hi Tutor
>
> The problem i have is to see which statements modify my data at execution
> time without referring to the code. Referring to the code is difficult esp
> because of branching. You can never tell before hand which branch execution
>
True both are assignments, L3, does change a value of any variable.
Johnson
On Thu, Jun 18, 2009 at 4:53 PM, Elisha Rosensweig wrote:
> It is not clear to me in what way line 3 is different than line 2 - both
> are assignments... Please clarify
>
> Elisha
>
> On Thu, Jun 18, 2009 at 10:37 AM,
On 6/18/2009 7:37 AM Jojo Mwebaze said...
Hi Tutor
The problem i have is to see which statements modify my data at
execution time without referring to the code. Referring to the code is
difficult esp because of branching. You can never tell before hand which
branch execution will follow.
e.
It is not clear to me in what way line 3 is different than line 2 - both are
assignments... Please clarify
Elisha
On Thu, Jun 18, 2009 at 10:37 AM, Jojo Mwebaze wrote:
> Hi Tutor
>
> The problem i have is to see which statements modify my data at execution
> time without referring to the code. R
David wrote:
> Kent Johnson wrote:
>
>> On Wed, Feb 11, 2009 at 11:21 PM, bob gailer wrote:
>>
>>
>>
> Thanks Alan and Kent,
> This works as expected;
>
> #!/usr/bin/python
> import sys
> import os
> import time
>
> def mod():
> """Find files modified today, given a file path."""
>
Kent Johnson wrote:
> On Wed, Feb 11, 2009 at 11:21 PM, bob gailer wrote:
>
>
Thanks Alan and Kent,
This works as expected;
#!/usr/bin/python
import sys
import os
import time
def mod():
"""Find files modified today, given a file path."""
now = time.strftime('%Y-%m-%d', time.localtime(
On Wed, Feb 11, 2009 at 11:21 PM, bob gailer wrote:
> David wrote:
>>
>> I get this error with the int(time.localtime())
>> start_of_today = int(time.localtime())
>> TypeError: int() argument must be a string or a number, not
>> 'time.struct_time'
>
> Should have been start_of_today = int(time.ti
"David" wrote
I really only want it to report when a file has been modified so
this seems to work,
#!/usr/bin/python
import sys
import os
import time
def mod():
"""Find files modified today, given a file path."""
latest = 0
now = time.strftime('%Y-%m-%d', time.localtime())
David wrote:
I get this error with the int(time.localtime())
start_of_today = int(time.localtime())
TypeError: int() argument must be a string or a number, not
'time.struct_time'
Should have been start_of_today = int(time.time())
--
Bob Gailer
Chapel Hill NC
919-636-4239
bob gailer wrote:
1) That can't be the entire program, as there is no call to Mod()!
Yep, it was lost in my copy paste
2) Convention says function names start with lower case. Save initial
caps for class names.
Thanks for the reminder, I had forgotten :)
3) Get rid of latest - that is why yo
On Wed, Feb 11, 2009 at 8:46 PM, bob gailer wrote:
> 5) It is not necessary to convert times to strings. You can get midnight
> today from int(time.localtime())
??
In [1]: import time
In [2]: time.localtime()
Out[2]: time.struct_time(tm_year=2009, tm_mon=2, tm_mday=11,
tm_hour=21, tm_min=20, tm
David wrote:
Hi Everyone and thanks for the list and your help.
In my adventure in learning Python (never programed before) I am
attempting to findout if a file has been modified today given a search
path. It is working somewhat. Here it is;
#!/usr/bin/python
import sys
import os
import time
"ammar azif" <[EMAIL PROTECTED]> wrote
I am running ubuntu as my development platform but
the application is targeted for windows machine.
Is there any platform dependent library that can help me
Assuming you mean platform *independent* library I suspect
the answer is no. Things like the ta
Subject: Re: [Tutor] Program launcher in taskbar
To: tutor@python.org
Date: Sunday, July 13, 2008, 9:00 AM
Ammar wrote...
> Is is possible to place my program icon in the system tray portion
> of the taskbar (like instant messaging applications)?
> The program will be launched by clickin
Ammar wrote...
> Is is possible to place my program icon in the system tray portion
> of the taskbar (like instant messaging applications)?
> The program will be launched by clicking on the icon. How to
> do this in python and which module should I use?
Are you on a Windows machine? Then you
"johnf" <[EMAIL PROTECTED]> wrote
> > Coming from Scotland I have no idea what that means!
>
> What no Girl Scout cookies in Scotland???:-)
Well we have girls and we have scouts and we have girls
who are in the scouts equivalent for girls - the brownies.
Brownies are a kind of cookie aren't they
On Wednesday 16 January 2008 02:44:25 pm Alan Gauld wrote:
> > It is, almost, (19 January 2008)GS cookie time in
> > CA.
>
> Coming from Scotland I have no idea what that means!
What no Girl Scout cookies in Scotland???:-)
--
John Fabiani
___
Tutor m
"Roger Maxwell" <[EMAIL PROTECTED]> wrote
> I would like to learn and teach my 2 girls a mini
> database GUI program in Python and
Since sqlite is included in the standard distribution
of Pythn 2.5 you might as well use that. It is easy to administer
and uses a simplified version of st
>I would like to learn and teach my 2 girls a mini
> database GUI program in Python and
>They are Girl Scouts (and advanced MS & HS
> students)
http://davidbau.com/archives/2005/07/29/haaarg_world.html
Alan
___
Tutor maillist - Tutor@py
Greetings,
Take a look at this page:
http://davidbau.com/python/learning.html
and also this one (by the same programmer):
http://davidbau.com/archives/2005/07/29/haaarg_world.html
Not only are these interesting reads, but also give a glimpse
into what it takes to teach kids computer programmin
>Question(s):
>Q01: Is this a 'reasonable' first project?
Yes. But I'd say do it in 2 phases. First do a command-line version, then do
the GUI.
>Q02: We can use either MAC or WinXP but which? Or both?
It realy doesn't matter
>Q03: Is this the appropriate forum?
Yes
_
Ricardo Aráoz wrote:
> looking at the simpler use, if you would have exception handling in :
>
> try :
> with open('/etc/passwd', 'r') as f:
> for line in f:
> print line
> ... more processing code ...
> except ExceptionsOnOpening :
> ... exception handling
Torsten Marek wrote:
>> try :
>> with open('/etc/passwd', 'r') as f:
>> for line in f:
>> print line
>> ... more processing code ...
>> except ExceptionsOnOpening :
>> ... exception handling
>> except :
>> ... exceptions inside the for
>>
>>
>>
>> Whereas
On Mo, 2008-01-07 at 21:15 -0300, Ricardo Aráoz wrote:
> Kent Johnson wrote:
> > Ricardo Aráoz wrote:
> >> PEP 0343 is not an
> >> example of clarity in the definition of a statement, it mixes
> >> justification with historic development with definition with actual
> >> equivalent code. Couldn't o
Kent Johnson wrote:
> Ricardo Aráoz wrote:
>> Kent Johnson wrote:
>>> from contextlib import nested
>>> with nested(open_file(self.direcciones), open_file(self.excluidas))
>>> as (fIncl, fExcl):
>>>
>> Nice! How would you add exception reporting to this?
>
> I don't have a good answer to tha
Kent Johnson wrote:
> Ricardo Aráoz wrote:
>> PEP 0343 is not an
>> example of clarity in the definition of a statement, it mixes
>> justification with historic development with definition with actual
>> equivalent code. Couldn't or wouldn't bother to understand it.
>
> Here is a better starting p
Ricardo Aráoz wrote:
> Kent Johnson wrote:
>> from contextlib import nested
>> with nested(open_file(self.direcciones), open_file(self.excluidas))
>> as (fIncl, fExcl):
>>
>
> Nice! How would you add exception reporting to this?
I don't have a good answer to that, that's why I didn't propos
Ricardo Aráoz wrote:
> PEP 0343 is not an
> example of clarity in the definition of a statement, it mixes
> justification with historic development with definition with actual
> equivalent code. Couldn't or wouldn't bother to understand it.
Here is a better starting point:
http://docs.python.org/w
Kent Johnson wrote:
> Jeff Younker wrote:
>
>> Or if you're using python 2.5 then you can use with statements:
>>
>> from __future__ import with_statements
>> from contextlib import closing
>> ...
>> def mails(self):
>> with closing(open_file(self.direcciones)) as fIncl:
>>with clo
Jeff Younker wrote:
>> Maybe it is my poor understanding of exception handling. My intention
>> here is to open the first file, if error then report in logging and
>> finish normally, else open the 2nd file, if error then report in
>> logging
>> close the 1st file and finish normally. If no error
Jeff Younker wrote:
> Or if you're using python 2.5 then you can use with statements:
>
> from __future__ import with_statements
> from contextlib import closing
> ...
> def mails(self):
> with closing(open_file(self.direcciones)) as fIncl:
>with closing(open_file(self.excluidas))
>
> Maybe it is my poor understanding of exception handling. My intention
> here is to open the first file, if error then report in logging and
> finish normally, else open the 2nd file, if error then report in
> logging
> close the 1st file and finish normally. If no error then process.
>
Right
Ok, now the "tested" version (has been corrected) :
#!/usr/bin/env python
import time
import smtplib
import email
import ConfigParser
import logging
class Mensaje(object) :
def __init__(self) :
cfg = ConfigParser.ConfigParser()
try :
cfg.readfp(open('config.cfg'))
Jeff Johnson wrote:
> I would like to "butt" in here and mention that this is some of the most
> useful information I have seen! I am a programmer of 25 years that is
> new to Python. This type of back and forth dialog on actual production
> code is extremely useful to learning the language.
Ok, new version.
In procesar() I tried getting rid of the outer try block and having
'return' instead of 'raise' in the inner try blocks but I didn't like
the result. I'd rather have one more indent level but have only one exit
point from the function.
Redesigned class Mensaje so that it now includ
Kent Johnson wrote:
> Ricardo Aráoz wrote:
>> Jeff Younker wrote:
>
>>> The enclosing try block isn't needed. More on this later.
>
>> Maybe it is my poor understanding of exception handling. My intention
>> here is to open the first file, if error then report in logging and
>> finish normally,
Ricardo Aráoz wrote:
> Jeff Younker wrote:
>> The enclosing try block isn't needed. More on this later.
> Maybe it is my poor understanding of exception handling. My intention
> here is to open the first file, if error then report in logging and
> finish normally, else open the 2nd file, if erro
Jeff Younker wrote:
> The procesar function is complicated. It tries to do several things
> that that are better done elsewhere. It needs to be broken up into
> several functions and methods. This also clarifies and isolates the
> exception handling.
>
>> def procesar(mensaje):
>>try :
>
The procesar function is complicated. It tries to do several things
that that are better done elsewhere. It needs to be broken up into
several functions and methods. This also clarifies and isolates the
exception handling.
> def procesar(mensaje):
>try :
The enclosing try block isn't need
I would like to "butt" in here and mention that this is some of the most
useful information I have seen! I am a programmer of 25 years that is
new to Python. This type of back and forth dialog on actual production
code is extremely useful to learning the language. I have done this
with Ed Le
Kent Johnson wrote:
> Ricardo Aráoz wrote:
>> Ok, here is a corrected new version, I hope.
>>
>> Kent, the fact that Mensaje.__init__ reads the message configuration is
>> by design (it's a feature, not a bug ;c) ).
>
> You misunderstood my suggestion. I would add a method to Mensaje that
> creat
1 - 100 of 144 matches
Mail list logo