|   | 1 |  initial version  | 
Well, using Python exceptions, you may define a division function like this:
def div(x,y):
    try:
         return x/y
    except ZeroDivisionError:
         return 1
It yields
sage: div(2,3)
2/3
sage: div(2,0)
1
sage: div(x,x-x)
1
|   | 2 |  No.2 Revision  | 
Well, using Python exceptions, you may define a division function like this:
def div(x,y):
div(x, y):
    try:
         return x/y
    except ZeroDivisionError:
         return 1
It yields
sage: div(2,3)
2/3
sage: div(2,0)
1
sage: div(x,x-x)
1
|   | 3 |  No.3 Revision  | 
Well, using Python exceptions, you may define a division function like this:
def div(x, y):
    try:
         return x/y
    except ZeroDivisionError:
         return 1
It yields
sage: div(2,3)
2/3
sage: div(2,0)
1
sage: div(x,x-x)
1
 Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
 
                
                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.