By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,965 Members | 1,450 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,965 IT Pros & Developers. It's quick & easy.

templatetaizing exceptions

P: n/a
alf
Hi,

I have a few places in the code where I use:

try:
code_block
except A:
exception_handling
the code block is different each time while exception_handling the same.

What would be the best technique to abstract that out?
--
A.
Nov 13 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
En Tue, 13 Nov 2007 01:09:12 -0300, alf <as*@me.xs4all.nlescribió:
I have a few places in the code where I use:

try:
code_block
except A:
exception_handling
the code block is different each time while exception_handling the same.

What would be the best technique to abstract that out?
A function?

try:
code_block
except A:
handle_exception()

--
Gabriel Genellina

Nov 13 '07 #2

P: n/a
On Tue, 13 Nov 2007 06:17:26 -0300, Gabriel Genellina wrote:
>
A function?

try:
code_block
except A:
handle_exception()
maybe
>>def handle(f, *args, **kw):
.... try:
.... return f(*args, **kw)
.... except A:
.... handle_exception()
>>def doSomething():
.... code_block
....
>>handle(doSomething)
cheers
Nov 13 '07 #3

P: n/a
alf
david wrote:
On Tue, 13 Nov 2007 06:17:26 -0300, Gabriel Genellina wrote:
>A function?

try:
code_block
except A:
handle_exception()

maybe
>>>def handle(f, *args, **kw):
... try:
... return f(*args, **kw)
... except A:
... handle_exception()
>>>def doSomething():
... code_block
...
>>>handle(doSomething)

cheers
thx - this might work ...

--
alfz1
Nov 13 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.