'int' object is not callable error in class
<p>In python 2.7, I am writing a class called <code>Zillion</code>, which is to act as a counter for very large integers. I believe I have it riddled out, but I keep running into <code>TypeError: 'int' object is not callable</code> , which seems to mean that at some point in my code I tried to call an <code>int</code> like it was a function. Many of the examples I found on this site were simply a mathematical error where the writer omitted an operator. I can't seem to find my error.</p>

<pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
  File "&lt;pyshell#3&gt;", line 1, in &lt;module&gt;
    z.increment()
TypeError: 'int' object is not callable
</code></pre>

<p>My code:</p>

<pre><code>class Zillion:
    def __init__(self, digits):
        self.new = []
        self.count = 0 # for use in process and increment
        self.increment = 1 # for use in increment
        def process(self, digits):
            if digits == '':
                raise RuntimeError
            elif digits[0].isdigit() == False:
                if digits[0] == ' ' or digits[0] == ',':
                    digits = digits[1:]
                else:
                    raise RuntimeError
            elif digits[0].isdigit():
                self.new.append(int(digits[0]))
                digits = digits[1:]
                self.count += 1
            if digits != '':
                    process(self, digits)
        process(self, digits)
        if self.count == 0:
            raise RuntimeError

        self.new2 = self.new  # for use in isZero

    def toString(self):
        self.mystring =''
        self.x = 0
        while self.x &lt; self.count:
            self.mystring = self.mystring + str(self.new[self.x])
            self.x += 1
        print(self.mystring)

    def isZero(self):
        if self.new2[0] != '0':
            return False
        elif self.new2[0] == '0':
            self.new2 = self.new2[1:]
            isZero(self)
        return True

    def increment(self):
        if self.new[self.count - self.increment] == 9:
            self.new[self.count - self.increment] = 0
            if isZero(self):
                self.count += 1
                self.new= [1] + self.new
            else:
                self.increment += 1
                increment(self)
        elif self.new[self.count - self.increment] != 9:
            self.new[self.count - self.increment] = self.new[self.count - self.increment] + 1
</code></pre>

<p>You have both an instance variable and a method named <code>increment</code> that seems to be your problem with that traceback at least.</p>

<p>in <code>__init__</code> you define <code>self.increment = 1</code> and that masks the method with the same name</p>

<p>To fix, just rename one of them (and if it's the variable name, make sure you change all the places that use it--like throughout the <code>increment</code> method)</p>

<p>One way to see what's happening here is to use <code>type</code> to investigate.  For example:</p>

<pre><code>&gt;&gt;&gt; type(Zillion.increment)
&lt;type 'instancemethod'&gt;
&gt;&gt;&gt; z = Zillion('5')
&gt;&gt;&gt; type(z.incremenet)
&lt;type 'int'&gt;
</code></pre>

python