Python AttributeError: 'module' object has no attribute 'atoi'
Question: I tried to run following program of using python 3.2 , there is error:
'module' object has no attribute 'atoi' Can anybody tell me what should I do
to fix this? i really appreciate it !

    
    
    import string
    def converttoint(str):
        try:
            value = string.atoi(str)
            return value
        except ValueError:
            return None
    


Answer: `string.atoi` has been deprecated for a _very_ long time. Since [Python
2.0](http://docs.python.org/2/library/string.html#string.atoi), in fact, and
it doesn't exist in Python 3.

Simply use

    
    
    value = int(s)
    

instead, and don't call your variable `str`. That's a bad habit, as it shadows
the builtin string type `str`.

