[Numpy-discussion] why not zerodivision error?

Chao YUE chaoyuejoy at gmail.com
Sun May 20 03:21:39 EDT 2012


Dear all,

could anybody give one sentence about this? why in the loop I didn't get
zerodivision error by when I explicitly do this, I get a zerodivision
error? thanks.

In [7]: for i in np.arange(-10,10):
        print 1./i
   ...:
-0.1
-0.111111111111
-0.125
-0.142857142857
-0.166666666667
-0.2
-0.25
-0.333333333333
-0.5
-1.0
inf
1.0
0.5
0.333333333333
0.25
0.2
0.166666666667
0.142857142857
0.125
0.111111111111

In [8]: 1/0.
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
/mnt/f/data/DROUGTH/<ipython-input-8-7e0bf5b37da6> in <module>()
----> 1 1/0.

ZeroDivisionError: float division by zero

In [9]: 1./0.
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
/mnt/f/data/DROUGTH/<ipython-input-9-3543596c47ff> in <module>()
----> 1 1./0.

ZeroDivisionError: float division by zero

In [10]: 1./0
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
/mnt/f/data/DROUGTH/<ipython-input-10-523760448f92> in <module>()
----> 1 1./0

ZeroDivisionError: float division by zero


Chao

-- 
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120520/b25f3b18/attachment.html>


More information about the NumPy-Discussion mailing list