[Tutor] Exception Handling and Stack traces

2010-09-10 Thread Michael Powe
o be able to give this script to someone who will want to be able to read the error output without having to be a Python programmer experienced in reading stack traces. e.g. a "Badly formed URL" message that tells them they set up the parameters for connecting to the web service incorrectly.

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Michael Powe
On Fri, Sep 10, 2010 at 03:56:51PM +0200, Peter Otten wrote: > Michael Powe wrote: > > > I can't work out how to suppress stacktrace printing when exceptions > > are thrown. > > [snip rant] > > It might have been a good idea to read a tutorial like &

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Michael Powe
examples that I am not aware of. It looks like you and Peter have pulled me out of the ditch and for that I am grateful. Thanks. mp -- Michael Powemich...@trollope.orgNaugatuck CT USA It could have been an organically based disturbance of the brain -- perhaps a tumor or a m

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Michael Powe
On Fri, Sep 10, 2010 at 04:42:35PM +0200, Peter Otten wrote: > Michael Powe wrote: > > On Fri, Sep 10, 2010 at 03:56:51PM +0200, Peter Otten wrote: > >> Michael Powe wrote: > >> > I can't work out how to suppress stacktrace printing when excepti

[Tutor] Trapping HTTP Authentication Failure

2010-09-10 Thread Michael Powe
n? Thanks. mp -- Michael Powemich...@trollope.orgNaugatuck CT USA "And I'd be a Libertarian, if they weren't all a bunch of tax-dodging professional whiners." -- Berke Breathed pgptBq2mUrmnN.pgp Description: PGP signature ___

Re: [Tutor] Trapping HTTP Authentication Failure

2010-09-11 Thread Michael Powe
connections, retries and fails each time. Thanks. mp -- Michael Powemich...@trollope.orgNaugatuck CT USA I hate a fellow whom pride, or cowardice, or laziness drives into a corner, and who does nothing when he is there but sit and ; let him come out as I do, and . -- Sa

Re: [Tutor] Trapping HTTP Authentication Failure

2010-09-11 Thread Michael Powe
ption and exit the loop. > If that's what you're finding, perhaps the quickest way is to > subclass urllib2.HTTPBasicAuthHandler, and override the > http_error_auth_reqed method (essentially keeping it exactly the > same apart from the

Re: [Tutor] Trapping HTTP Authentication Failure

2010-09-11 Thread Michael Powe
e loop. Actually, there's a comment in the code about why it is set to 5 -- it's arbitrary, and allows for the Password Manager to prompt for credentials while not letting the request be reissued until 'recursion depth is exceeded.' I guess I'll have to go back to ground

Re: [Tutor] Trapping HTTP Authentication Failure

2010-09-11 Thread Michael Powe
On Sat, Sep 11, 2010 at 10:48:13AM -0400, Michael Powe wrote: > On Sat, Sep 11, 2010 at 02:25:24PM +0200, Evert Rol wrote: > > > > > >> I'm not sure what you're exactly doing here, or what you're getting, > > >> but I did get curious and d

[Tutor] SOLVED: Re: Trapping HTTP Authentication Failure

2010-09-11 Thread Michael Powe
-0400, Michael Powe wrote: > On Sat, Sep 11, 2010 at 10:48:13AM -0400, Michael Powe wrote: > > On Sat, Sep 11, 2010 at 02:25:24PM +0200, Evert Rol wrote: > > > > > > > > >> I'm not sure what you're exactly doing here, or what you're getting, &g

[Tutor] Documenting a Module

2010-09-13 Thread Michael Powe
f its functionality from the comments and doc strings; and I already wasted a considerable part of my Sunday afternoon trying to get along with Sphinx. I'm not talking about a huge Python project, nor am I likely to need that type of documentation tool in the near future. Thanks. mp -- Mi

Re: [Tutor] wierd replace problem

2010-09-13 Thread Michael Powe
'tis', 1), > > Why does the \ stays here. It should have gone as the test in the python > prompt says. > > Roelof > > > > ___ > Tutor maillist - Tutor@python.org > T

Re: [Tutor] Documenting a Module

2010-09-13 Thread Michael Powe
; Ralf > ?? > ?? > ?? Thank you, much appreciated. mp -- Michael Powemich...@trollope.orgNaugatuck CT USA 47.3% of all statistics are made up on the spot. - Steven Wright pgpZzxvhgS3f7.pgp Description: PGP signature _

Re: [Tutor] wierd replace problem

2010-09-13 Thread Michael Powe
replace(), it's there to escape the single quote, which is appearing in the middle of a single-quoted string. IF the double-quote had not also been there, python would have replaced the outer quotes with double quotes, as it does on my system before I got to thinking about that lonely double

Re: [Tutor] Documenting a Module

2010-09-13 Thread Michael Powe
want to follow up that epydoc is completely awesome and exactly the right tool for the job. I was able to get my doc generated and wrapped up nicely in less time than I spent trying to get Sphinx installed yesterday. Thanks. mp -- Michael Powemich...@trollope.orgNaugatuck

[Tutor] A Plea for Sensible Quoting

2010-09-14 Thread Michael Powe
of the mail. A little formatting goes a long way. Thanks. mp -- Michael Powemich...@trollope.orgNaugatuck CT USA Fun experiments: Get a can of shaving cream, throw it in a freezer for about a week. Then take it out, peel the metal off and put it where you want..

Re: [Tutor] re.findall parentheses problem

2010-09-14 Thread Michael Powe
r group 3. Just matcher.group('January'). Thanks. mp -- Michael Powemich...@trollope.orgNaugatuck CT USA "We had pierced the veneer of outside things. We had `suffered, starved, and triumphed, groveled down yet grasped at glory, grown bigger in the bigness of

[Tutor] Regex comments

2010-09-16 Thread Michael Powe
x27;t see one. The point would be that in my processing of the match, I could implement the comments as identifiers for the matched value. Thanks. mp -- Michael Powemich...@trollope.orgNaugatuck CT USA "The most likely way for the world to be destroyed, most exper

Re: [Tutor] Regex comments

2010-09-16 Thread Michael Powe
On Thu, Sep 16, 2010 at 01:31:09PM +0200, Peter Otten wrote: > Michael Powe wrote: > > The re module includes the option to comment a regular expression with > > the syntax (?#comment). e.g. > > Is there a mechanism for extracting these values from the match, in > &g

[Tutor] "Overloading" methods

2010-09-16 Thread Michael Powe
to put all the parsing code in one method. My question is, is this a bad thing to do in python? Thanks. mp -- Michael Powemich...@trollope.orgNaugatuck CT USA War is a sociological safety valve that cleverly diverts popular hatred for the ruling classes into a happy o

[Tutor] Comparing two lists

2010-09-16 Thread Michael Powe
xcrutiatingly painful 'for' loops. Looking for something more efficient and elegant. Thanks. mp -- Michael Powemich...@trollope.orgNaugatuck CT USA "The secret to strong security: less reliance on secrets." -- Whitfield Diffie pgpbadqbDTu

Re: [Tutor] Comparing two lists

2010-09-16 Thread Michael Powe
On Thu, Sep 16, 2010 at 12:59:08PM -0600, Vince Spicer wrote: > On Thu, Sep 16, 2010 at 12:49 PM, Vince Spicer wrote: > > On Thu, Sep 16, 2010 at 12:27 PM, Michael Powe wrote: > >> alist = ['label', 'guid'] > >> blist = ['column0label&#

Re: [Tutor] Comparing two lists

2010-09-16 Thread Michael Powe
On Thu, Sep 16, 2010 at 12:59:08PM -0600, Vince Spicer wrote: > On Thu, Sep 16, 2010 at 12:49 PM, Vince Spicer wrote: > > On Thu, Sep 16, 2010 at 12:27 PM, Michael Powe wrote: > >> I have two lists. > >> alist = ['label', 'guid'] &

Re: [Tutor] Best Python Editor

2009-06-14 Thread Michael Powe
On Sun, Jun 14, 2009 at 12:53:19PM -0700, Emile van Sebille wrote: > On 6/14/2009 8:04 AM Alan Gauld said... > >"Tom Green" wrote > >>Since VIM seems to be the editor of choice and I have been programming in > >>Python for many years using Pyscripter and Eclipse I was wondering how I > >>could t

Re: [Tutor] Best Python Editor

2009-06-15 Thread Michael Powe
On Mon, Jun 15, 2009 at 06:30:50AM -0700, johnf wrote: > On Sunday 14 June 2009 07:31:53 pm Michael Powe wrote: > > However, I will say that while following this thread, it occurred to > > me that the one feature that VS and even the VBA editor in MS Office > > has, is the ab

Re: [Tutor] Best Python Editor

2009-06-15 Thread Michael Powe
On Mon, Jun 15, 2009 at 06:34:04AM -0700, Emile van Sebille wrote: > On 6/15/2009 2:49 AM Tom Green said... > >Yes, vim or any text editor is suitable for Python, but I > >prefer having a nice GUI interface while coding. I mean the automobile > >replaced the horse and buggy, while they both get

[Tutor] here documents

2005-01-03 Thread Michael Powe
Hello, In perl, I create variables of fairly involved text using here documents. For example, $msg = <<"EOF"; a bunch of text here. ... EOF Is there an equivalent method in python? I usually use this method when creating help messages for scripts -- put all the text into a variable and the

Re: [Tutor] here documents

2005-01-03 Thread Michael Powe
On Mon, Jan 03, 2005 at 11:54:06PM -, Alan Gauld wrote: > There was a detailed thread on this recently either here > or on usenet group comp.lang.python... I checked the archives for this list but didn't see anything. I'll try the ng. Thanks. > The bottom line was to use string formatting

Re: [Tutor] Re: here documents

2005-01-03 Thread Michael Powe
On Mon, Jan 03, 2005 at 10:04:18PM -0200, Jorge Luiz Godoy Filho wrote: > Alan Gauld, Segunda 03 Janeiro 2005 21:56, wrote: > > > Oops, those should have been () not {} > > I always do the same mistake ;-) Using "{}" seems more intuitive to me. perhaps because of ${var} shell syntax? ;-) mp

[Tutor] regex problem

2005-01-04 Thread Michael Powe
Hello, I'm having erratic results with a regex. I'm hoping someone can pinpoint the problem. This function removes HTML formatting codes from a text email that is poorly exported -- it is supposed to be a text version of an HTML mailing, but it's basically just a text version of the HTML page.

Re: [Tutor] regex problem

2005-01-05 Thread Michael Powe
On Tue, Jan 04, 2005 at 09:15:46PM -0800, Danny Yoo wrote: > > > On Tue, 4 Jan 2005, Michael Powe wrote: > > > def parseFile(inFile) : > > import re > > bSpace = re.compile("^ ") > > multiSpace = re.compile(r"\s\s+&

Re: [Tutor] regex problem

2005-01-05 Thread Michael Powe
On Wed, Jan 05, 2005 at 07:37:58AM -, Alan Gauld wrote: > > This function removes HTML formatting codes from a text email > Using regex to remove HTML is usually the wrong approach unless > you can guarantee the format of the HTML in advance. The > HTMLparser is usually better and simpler.

Re: [Tutor] regex problem

2005-01-05 Thread Michael Powe
On Wed, Jan 05, 2005 at 06:33:32AM -0500, Kent Johnson wrote: > If you search comp.lang.python for 'convert html text', the top four > results all have solutions for this problem including a reference to this > cookbook recipe: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52297 > >

Re: [Tutor] Something is wrong in file input output functions.

2005-01-10 Thread Michael Powe
On Mon, Jan 10, 2005 at 12:15:18PM -0800, kumar s wrote: > Dear group, > I have written a small piece of code that takes a file > and selects the columns that I am interested in and > checks the value of the column on a condition (value > that eqauls 25) and then write it the to another file. > >

[Tutor] Clash of the Titans and Mundane Matters

2005-01-19 Thread Michael Powe
Clash of the Titans >From "Dive into Python": __init__ is called immediately after an instance of the class is created. It would be tempting but incorrect to call this the constructor of the class. It's tempting, because it looks like a constructor (by convention, __init__ is the first method def