Strange argument count error - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Strange argument count error (/thread-40482.html) |
Strange argument count error - rowan_bradley - Aug-05-2023 I am trying to call a function in a library written by someone else. Here is my code: import growattServer import datetime import time from datetime import date import getpass import json import sys, getopt import shutil from enum import IntEnum # set up variables user_name = "rowan.bradley" # Server username user_pass = "xxxxxxxxxxxxx" # server password outFolder = "/growatt" outPrefix = "growatt-" outSuffix = ".json" class Timespan(IntEnum): hour = 0 day = 1 month = 2 api = growattServer.GrowattApi(False, "hue73jhns83je93jed723uj2") login_response = api.login(user_name, user_pass) today = date.fromtimestamp(time.time()) inverter_detail = api.inverter_detail('OOCTCHT07L', today) print("inverter_detail = ", inverter_detail)This what happens when I run this: D:\XPS_8700 Extended Files\Users\RowanB\Documents\Inetpub\www.sylvesterbradley.org\public_html>python -O growatt3.py Traceback (most recent call last): File "D:\XPS_8700 Extended Files\Users\RowanB\Documents\Inetpub\www.sylvesterbradley.org\public_html\growatt3.py", line 26, in <module> inverter_detail = api.inverter_detail('OOCTCHT07L', today) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: GrowattApi.inverter_detail() takes 2 positional arguments but 3 were given D:\XPS_8700 Extended Files\Users\RowanB\Documents\Inetpub\www.sylvesterbradley.org\public_html>Why does it say that three arguments were given although it is clear from the call that there were only 2? How do I get this call to work? Thank you - Rowan RE: Strange argument count error - snippsat - Aug-05-2023 (Aug-05-2023, 04:57 PM)rowan_bradley Wrote: Why does it say that three arguments were given although it is clear from the call that there were only 2? How do I get this call to work?It take only one argument inverter_id Methods.inverter_detail = api.inverter_detail('OOCTCHT07L')So is it ok for you to post the server password? I did remove it from your last Thread. RE: Strange argument count error - deanhystad - Aug-06-2023 This is 2 arguments: api.inverter_detail('OOCTCHT07L')Because python passes api as the first argument.: api.__class__.inverter_detail(api, 'OOCTCHT07L') RE: Strange argument count error - rowan_bradley - Aug-06-2023 (Aug-05-2023, 06:51 PM)snippsat Wrote: So is it ok for you to post the server password?I think it's OK. I included it so that people could try the code and see what is wrong (which one person has already done). I did think about it before including it. Thank you - Rowan |