Guarding arithmetic
Mark Carter
alt.mcarter at gmail.com
Thu Aug 23 05:22:30 EDT 2012
On Thursday, 23 August 2012 10:16:08 UTC+1, Chris Angelico wrote:
> On Thu, Aug 23, 2012 at 7:05 PM, Mark Carter <> wrote:
> > Suppose I want to define a function "safe", which returns the argument passed if there is no error, and 42 if there is one.
> only possible with floating point, not integer.
>
> try:
> print 1/0
> except ZeroDivisionError:
> print 42
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.
More information about the Python-list
mailing list