Answered by : carlos-santos-pinto
"""
This might pop up if you're trying to use a class directly,
rather than instantiating it. The "missing" argument is "self"
corresponding to the object that you didn't instantiate
"""
class MyClass: def __init__(self, attr) -> None: self.attr = attr def get_attr (self): return self.attr
# CORRECT
object_of_myclass = MyClass(1)
print (type(object_of_myclass)) # <class '__main__.MyClass'>
print (object_of_myclass.get_attr()) # 1
# INCORRECT
myclass = MyClass
print (type(myclass)) # <class 'type'>
print (myclass.get_attr())
# TypeError: get_attr() missing 1 required positional argument: 'self'
Source : | Last Update : Wed, 09 Jun 21
Answered by : code-grepper
{"tags":[{"tag":"p","content":"You have reached your max daily Grepper answers. <a href=\"https://www.grepper.com/subscriptions.php\" target=\"_blank\" rel=\"nofollow\">Upgrade to professional </a>to view more Grepper answer today."},{"tag":"p","content":"<a href=\"https://www.grepper.com/api/view_product.php?hl=1&pid=42\" target=\"_blank\" rel=\"nofollow\">Upgrade To Grepper Professional</a>"}]}
Source : | Last Update : Mon, 27 Mar 23
Answered by : vivek-dhage
from django.http import JsonResponse
from django.shortcuts import render, HttpResponse
import requests
import pandas as pd
from rest_framework.views import APIView
from rest_framework.response import Response
class ChartData(APIView): authentication_classes = [] permission_classes = [] def get(self, request, format=None): data = { 'customer' : 10, 'sales': 100 } return Response(data)
#just remove self from bellow function it's unnecessary
#before def get_indiceComercioVarejista(self, request, format=None): data = { 'customer' : 10, 'sales': 100 } return Response(data)
#after def get_indiceComercioVarejista(request, format=None): data = { 'customer' : 10, 'sales': 100 } return Response(data)
Source : https://stackoverflow.com/questions/45720065/django-missing-1-required-positional-argument-request | Last Update : Tue, 31 May 22
Answered by : habib-ur-rehman-q6x0qrjlql27
syntax should be this
user_profile = UserProfile()
Source : https://stackoverflow.com/questions/46907511/typeerror-save-missing-1-required-positional-argument-self | Last Update : Fri, 14 Oct 22
Answered by : adrian-folie
dialog = textbox1.get("1.0",'end-1c')
subject = textbox2.get("1.0",'end-1c')
Source : https://stackoverflow.com/questions/63525858/typeerror-get-missing-1-required-positional-argument-index1 | Last Update : Sat, 18 Jun 22
Answered by : annoying-alpaca-h5pwrc34uxvc
p = Pump()
p.getPumps()
Source : https://stackoverflow.com/questions/17534345/typeerror-missing-1-required-positional-argument-self | Last Update : Fri, 23 Sep 22