subclass of integers
Roberto Bonvallet
rbonvall at gmail.com
Sun Sep 16 01:21:31 EDT 2007
On Sep 14, 10:30 am, Mark Morss <mfmo... at aep.com> wrote:
> I would like to construct a class that includes both the integers and
> None. I desire that if x and y are elements of this class, and both
> are integers, then arithmetic operations between them, such as x+y,
> return the same result as integer addition. However if either x or y
> is None, these operations return None.
No need to create a new class:
try:
result = a * b
except TypeError:
result = None
--
Roberto Bonvallet
More information about the Python-list
mailing list