title: AttributeError: FUN instance has no attribute '__trunc__'
body: <p>here is my class FUN, but the result is showing <code>AttributeError: FUN instance has no attribute '__trunc__'</code>. please tell me where is the error in coding and what to modify.</p>
  
  <pre><code>import math
  import random
  import string
  import numpy as np
  import pickle
  from itertools import chain
  
  random.seed(0)
  
  class FUN:
   def __init__(self):
      print "fun"
   # set a random numbers between a &amp; b
   def rand(a, b):
      self.rand = (b-a)*random.random() + a
      return self.rand
  
   # sigmoid function, tanh ~ 1/(1+e^-x)
   def sigmoid(x):
       self.sig = math.tanh(x)
       return self.sig
  
   def sigmoid1(x):
      self.sig1 = 1/(1+math.exp(-x))
      return self.sig1
  
   # derivative of sigmoid function, in terms of the output (y)
   def dsigmoid(y):
      self.dsig = 1.0 - y**2
      return self.dsig
   # getting 2d array
   #def matrix(I, J, fill=0.0):
      #return [[val for col in range(I)] for row in range(J)]
   #obtain a matrix
   def matrix(I, J, fill=0.0):
      m = []
      for i in range(I):
          m.append([fill]*J)
      return m
  f = FUN()
  print f.matrix(2,3)
  </code></pre>
  
  <p>the above code is giving the following type of errors:</p>
  
  <pre><code>fun
  Traceback (most recent call last):
  File "functions.py", line 42, in &lt;module&gt;
   print f.matrix(2,3)
  File "functions.py", line 38, in matrix
   for i in range(I):
  AttributeError: FUN instance has no attribute '__trunc__'
  </code></pre>
  
  <p>please help me to resolve this error.</p>