Python Forum
Strange argument count error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strange argument count error
#1
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
Larz60+ write Aug-06-2023, 12:19 AM:
removed sensitive information
Reply
#2
(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.
Reply
#3
This is 2 arguments:
api.inverter_detail('OOCTCHT07L')
Because python passes api as the first argument.:
api.__class__.inverter_detail(api, 'OOCTCHT07L')
Reply
#4
(Aug-05-2023, 06:51 PM)snippsat Wrote: So is it ok for you to post the server password?
I did remove it from your last Thread.
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Row Count and coloumn count Yegor123 4 1,337 Oct-18-2022, 03:52 AM
Last Post: Yegor123
  Error: _vhstack_dispatcher() takes 1 positional argument but 9 were given alexfrol86 3 5,847 May-09-2022, 12:49 PM
Last Post: deanhystad
  Strange error ValueError: dimension mismatch Anldra12 0 1,982 Aug-17-2021, 07:54 AM
Last Post: Anldra12
  int() argument Error.... but it's not :) LeoT 2 1,875 Feb-24-2021, 06:58 PM
Last Post: buran
  List of error codes to find (and count) in all files in a directory tester_V 8 3,716 Dec-11-2020, 07:07 PM
Last Post: tester_V
  Strange syntax error with f-strings Askic 6 4,229 Oct-16-2020, 10:40 AM
Last Post: Askic
  SyntaxError: positional argument follows keyword argument syd_jat 3 5,851 Mar-03-2020, 08:34 AM
Last Post: buran
  Syntax Error with Argument Parser aditya_man 1 3,930 Sep-30-2019, 01:21 PM
Last Post: ichabod801
  Invalid argument error thrown. pyseeker 4 8,624 Sep-10-2019, 07:03 PM
Last Post: pyseeker
  Type error: dump() missing 1 required positional argument: fp jaycuff13 2 21,959 Jul-13-2019, 10:21 AM
Last Post: jaycuff13

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020