Search code examples
pythonclasssmartsheet-api

can't workout why getting a type error on __init__


Hope someone can help me...

Have the following:

smartsheet_test.py

from pfcms.content import Content

def main():
    ss = Content()
    ss.smartsheet()

if __name__ == "__main__":
    main()

content.py

import smartsheet as ss
class Content:
    """ PFCMS SmartSheet utilities """
    def __init__(self):
        self.token = 'xxxxxxxxxxxxxxxxxxx'

    def smartsheet(self):
         smartsheet = ss.Smartsheet(self.token)

however when I execute the code I get:

python -d smartsheet_test.py 
Traceback (most recent call last):
File "smartsheet_test.py", line 8, in <module>
main()
File "smartsheet_test.py", line 5, in main
ss.smartsheet()
File "/xxxxx/pfcms/pfcms/content.py",     line 10, in smartsheet
smartsheet = ss.Smartsheet(self.token)
TypeError: __init__() takes exactly 1 argument (2 given)

is self being passed into ss.Smartsheet(self.token) somehow, all I can see is that I'm passing the argument self.token. My knowledge of Python isn't too deep at this point. Any help greatly appreciated.

Thanks Alex


Solution

  • You have (or had) a file called smartsheet.py in your current working directory. Delete or rename that file, and delete any related .pyc file.