ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
exceptions
by lbates other posts by this author
Jun 1 2004 8:55AM messages near this date
exceptions | exceptions
I'm going to jump in here and make an observation.
It sounds like you have too much code in a single
try/except block.  If you have independent calls
to instrument interface put each of them that might
fail in a separate try/except block.  I've needed
to do this in an earlier project and I log errors
in a log file for review.

Something like:

try: data=getsomedatafrominstrumentfunc1()
except:
    logf.writelines("W","Unable to communicate with func1")

try: data=getsomedatafrominstrumentfunc2()
except:
    logf.writelines("W","Unable to communicate with func2")

My understanding is that try/except overhead is very low
(especially if there is not an exception).

HTH,
Larry Bates
Syscon, Inc.

"Zunbeltz Izaola" <zunbeltz@[...].XXX>  wrote in message
news:cthvfiblpo4.fsf@[...]..
>  Peter Hansen <peter@[...].com> writes:
> 
> 
>  > Pardon: I don't know why I thought this was related to testing
>  > code.
> 
>  No problem :-)
> 
>  >
>  > > My program is controling and instrument (an x-ray powder
>  > > diffractometer) and some parts of the instrument are not working for
>  > > the moment, so i want to disable all error i get from this instrument
>  > > (are coded like exceptions)
>  >
>  > What is the interface to the instrument?  Is there some sort of
>  > driver/wrapper layer that handles the communication with the
>  > device?  Your only hope, I think, is to intercept things at
>  > that level and avoid/trap the exceptions before they get up
>  > to the higher level.  In effect, stubs as Irmen suggested...
>  >
> 
>  Finally I do something similar to Irmen's suggestion.
> 
>  > It sounds like you are quite capable of figuring it out at
>  > this point, though, since all you wanted to know was whether
>  > you could continue after an exception and now you know you
>  > cannot. :-)
>  >
> 
>  Yes, I only wanted to know if there was an easy way to continue after
>  an exception; and I can't (nobody can :-)
> 
>  Thanks to all for your answers (and sorry for re-starting and annual
>  thread)
> 
>  Zunbeltz
> 
>  > -Peter
> 
>  -- 
>  Zunbeltz Izaola Azkona                    |  wmbizazz at lg dot ehu
>  dotes
>  Materia Kondentsatuaren Fisika Saila      |
>  Zientzia eta Teknologia Fakultatea        |  Phone: 34946015326
>  Euskal Herriko Unibertsitatea             |
>  PK 644                                    |  Fax:   34 944648500
>  48080 Bilbo (SPAIN)                       |
Thread:
A Schmolck
hungjunglu
Michele Simionato
hungjunglu
peter
A Schmolck
Jacek Generowicz
Michele Simionato
Michele Simionato
hungjunglu
hungjunglu
A Schmolck
A Schmolck
hungjunglu
A Schmolck
mwh
hungjunglu
lbates
jjl
peter

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved