On Thu, Aug 23, 2012 at 7:22 PM, Mark Carter <alt.mcar...@gmail.com> wrote:
> OK, so it looks like a solution doesn't exist to the problem as specified. I 
> guess it's something that only a language with macros could accommodate.

You're asking for a function to prevent the evaluation of its
arguments from throwing an error. That's fundamentally not possible
with a function call. Exception handling is a much more normal way of
handling it; though if you prefer, you could wrap it up in a function
like this:

def safe_div(num,denom):
  try:
    return num/denom
  except ZeroDivisionError:
    return 42

print safe_div(1,0)  # still a poor name though

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to