How do i solve“ missing 1 required positional argument ”












-3















I wrote a method in class and got the following error



yearLinks = link(root_url + '/oilmarketreport/reports/')
TypeError: link() missing 1 required positional argument: 'url'


My code is:-



class Data:
def __init__(self):
try: ------
----
else:

def link(self, url):

all_links =
page = requests.get(url)
soup = BeautifulSoup(page.text, 'html.parser')
for href in soup.find_all(class_='omrlist'):
all_links.append(root_url + href.find('a').get('href'))
return all_links
yearLinks = link(root_url + '/oilmarketreport/reports/')
reportLinks =
for url in yearLinks:
links = link(url)


So how i solve this in python.










share|improve this question

























  • What is links?

    – Loocid
    Nov 23 '18 at 5:58











  • You needs to use self.links(url) or self.link(url) depending on what named your method.

    – Red Cricket
    Nov 23 '18 at 5:59








  • 3





    the indentation is not clear.

    – b-fg
    Nov 23 '18 at 6:00











  • links is variable having all links which we need

    – royal
    Nov 23 '18 at 6:03











  • @ Red Cricket, links is variable name and link is method name

    – royal
    Nov 23 '18 at 6:06
















-3















I wrote a method in class and got the following error



yearLinks = link(root_url + '/oilmarketreport/reports/')
TypeError: link() missing 1 required positional argument: 'url'


My code is:-



class Data:
def __init__(self):
try: ------
----
else:

def link(self, url):

all_links =
page = requests.get(url)
soup = BeautifulSoup(page.text, 'html.parser')
for href in soup.find_all(class_='omrlist'):
all_links.append(root_url + href.find('a').get('href'))
return all_links
yearLinks = link(root_url + '/oilmarketreport/reports/')
reportLinks =
for url in yearLinks:
links = link(url)


So how i solve this in python.










share|improve this question

























  • What is links?

    – Loocid
    Nov 23 '18 at 5:58











  • You needs to use self.links(url) or self.link(url) depending on what named your method.

    – Red Cricket
    Nov 23 '18 at 5:59








  • 3





    the indentation is not clear.

    – b-fg
    Nov 23 '18 at 6:00











  • links is variable having all links which we need

    – royal
    Nov 23 '18 at 6:03











  • @ Red Cricket, links is variable name and link is method name

    – royal
    Nov 23 '18 at 6:06














-3












-3








-3








I wrote a method in class and got the following error



yearLinks = link(root_url + '/oilmarketreport/reports/')
TypeError: link() missing 1 required positional argument: 'url'


My code is:-



class Data:
def __init__(self):
try: ------
----
else:

def link(self, url):

all_links =
page = requests.get(url)
soup = BeautifulSoup(page.text, 'html.parser')
for href in soup.find_all(class_='omrlist'):
all_links.append(root_url + href.find('a').get('href'))
return all_links
yearLinks = link(root_url + '/oilmarketreport/reports/')
reportLinks =
for url in yearLinks:
links = link(url)


So how i solve this in python.










share|improve this question
















I wrote a method in class and got the following error



yearLinks = link(root_url + '/oilmarketreport/reports/')
TypeError: link() missing 1 required positional argument: 'url'


My code is:-



class Data:
def __init__(self):
try: ------
----
else:

def link(self, url):

all_links =
page = requests.get(url)
soup = BeautifulSoup(page.text, 'html.parser')
for href in soup.find_all(class_='omrlist'):
all_links.append(root_url + href.find('a').get('href'))
return all_links
yearLinks = link(root_url + '/oilmarketreport/reports/')
reportLinks =
for url in yearLinks:
links = link(url)


So how i solve this in python.







python methods typeerror






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 6:39







royal

















asked Nov 23 '18 at 5:56









royalroyal

229




229













  • What is links?

    – Loocid
    Nov 23 '18 at 5:58











  • You needs to use self.links(url) or self.link(url) depending on what named your method.

    – Red Cricket
    Nov 23 '18 at 5:59








  • 3





    the indentation is not clear.

    – b-fg
    Nov 23 '18 at 6:00











  • links is variable having all links which we need

    – royal
    Nov 23 '18 at 6:03











  • @ Red Cricket, links is variable name and link is method name

    – royal
    Nov 23 '18 at 6:06



















  • What is links?

    – Loocid
    Nov 23 '18 at 5:58











  • You needs to use self.links(url) or self.link(url) depending on what named your method.

    – Red Cricket
    Nov 23 '18 at 5:59








  • 3





    the indentation is not clear.

    – b-fg
    Nov 23 '18 at 6:00











  • links is variable having all links which we need

    – royal
    Nov 23 '18 at 6:03











  • @ Red Cricket, links is variable name and link is method name

    – royal
    Nov 23 '18 at 6:06

















What is links?

– Loocid
Nov 23 '18 at 5:58





What is links?

– Loocid
Nov 23 '18 at 5:58













You needs to use self.links(url) or self.link(url) depending on what named your method.

– Red Cricket
Nov 23 '18 at 5:59







You needs to use self.links(url) or self.link(url) depending on what named your method.

– Red Cricket
Nov 23 '18 at 5:59






3




3





the indentation is not clear.

– b-fg
Nov 23 '18 at 6:00





the indentation is not clear.

– b-fg
Nov 23 '18 at 6:00













links is variable having all links which we need

– royal
Nov 23 '18 at 6:03





links is variable having all links which we need

– royal
Nov 23 '18 at 6:03













@ Red Cricket, links is variable name and link is method name

– royal
Nov 23 '18 at 6:06





@ Red Cricket, links is variable name and link is method name

– royal
Nov 23 '18 at 6:06












3 Answers
3






active

oldest

votes


















1














you have to do self.link(url). Its missing the self parameter.
Edit:



you can update the line as:



yearLinks = self.link(root_url + '/oilmarketreport/reports/')






share|improve this answer


























  • No sir. error is comming in the yearLinks veriable. yearlinks veriable is not in any method

    – royal
    Nov 23 '18 at 6:50













  • updated the answer

    – Omair Shamshir
    Nov 23 '18 at 7:02











  • Sir prob is not solve yet please guide. need to integrate my code to other code So..

    – royal
    Nov 23 '18 at 7:30













  • I think the indentation of the code in your question doesn't match your real code. Until you fix that, we won't be able to help.

    – Matthias
    Nov 23 '18 at 8:40





















0














it's an unclear question. maybe staticmethod is what you wanted.



class Data:
def __init__(self):
try: ------
----
else:
@staticmethod
def link(url):

all_links =
page = requests.get(url)
soup = BeautifulSoup(page.text, 'html.parser')
for href in soup.find_all(class_='omrlist'):
all_links.append(root_url + href.find('a').get('href'))
return all_links
yearLinks = Data.link(root_url + '/oilmarketreport/reports/')
reportLinks =
for url in yearLinks:
links = Data.link(url)





share|improve this answer
























  • yearLinks = Data.link(root_url + '/oilmarketreport/reports/') NameError: name 'Data' is not defined

    – royal
    Nov 23 '18 at 9:00













  • I need to integrate my to to other code So need to put all code in class and method format. during that got above error

    – royal
    Nov 23 '18 at 9:03











  • @royal can you check the indention? that's weird. you put code in a class.

    – Kevin Chan
    Nov 24 '18 at 13:24



















0














Just for clearness:



class Data:
def __init__(self):
""""""

@staticmethod
def link(url):
return url


print(Data.link("some_link")) # call method of class Data (will print "some_link")





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441308%2fhow-do-i-solve-missing-1-required-positional-argument%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    you have to do self.link(url). Its missing the self parameter.
    Edit:



    you can update the line as:



    yearLinks = self.link(root_url + '/oilmarketreport/reports/')






    share|improve this answer


























    • No sir. error is comming in the yearLinks veriable. yearlinks veriable is not in any method

      – royal
      Nov 23 '18 at 6:50













    • updated the answer

      – Omair Shamshir
      Nov 23 '18 at 7:02











    • Sir prob is not solve yet please guide. need to integrate my code to other code So..

      – royal
      Nov 23 '18 at 7:30













    • I think the indentation of the code in your question doesn't match your real code. Until you fix that, we won't be able to help.

      – Matthias
      Nov 23 '18 at 8:40


















    1














    you have to do self.link(url). Its missing the self parameter.
    Edit:



    you can update the line as:



    yearLinks = self.link(root_url + '/oilmarketreport/reports/')






    share|improve this answer


























    • No sir. error is comming in the yearLinks veriable. yearlinks veriable is not in any method

      – royal
      Nov 23 '18 at 6:50













    • updated the answer

      – Omair Shamshir
      Nov 23 '18 at 7:02











    • Sir prob is not solve yet please guide. need to integrate my code to other code So..

      – royal
      Nov 23 '18 at 7:30













    • I think the indentation of the code in your question doesn't match your real code. Until you fix that, we won't be able to help.

      – Matthias
      Nov 23 '18 at 8:40
















    1












    1








    1







    you have to do self.link(url). Its missing the self parameter.
    Edit:



    you can update the line as:



    yearLinks = self.link(root_url + '/oilmarketreport/reports/')






    share|improve this answer















    you have to do self.link(url). Its missing the self parameter.
    Edit:



    you can update the line as:



    yearLinks = self.link(root_url + '/oilmarketreport/reports/')







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 23 '18 at 7:02

























    answered Nov 23 '18 at 6:42









    Omair ShamshirOmair Shamshir

    1,734821




    1,734821













    • No sir. error is comming in the yearLinks veriable. yearlinks veriable is not in any method

      – royal
      Nov 23 '18 at 6:50













    • updated the answer

      – Omair Shamshir
      Nov 23 '18 at 7:02











    • Sir prob is not solve yet please guide. need to integrate my code to other code So..

      – royal
      Nov 23 '18 at 7:30













    • I think the indentation of the code in your question doesn't match your real code. Until you fix that, we won't be able to help.

      – Matthias
      Nov 23 '18 at 8:40





















    • No sir. error is comming in the yearLinks veriable. yearlinks veriable is not in any method

      – royal
      Nov 23 '18 at 6:50













    • updated the answer

      – Omair Shamshir
      Nov 23 '18 at 7:02











    • Sir prob is not solve yet please guide. need to integrate my code to other code So..

      – royal
      Nov 23 '18 at 7:30













    • I think the indentation of the code in your question doesn't match your real code. Until you fix that, we won't be able to help.

      – Matthias
      Nov 23 '18 at 8:40



















    No sir. error is comming in the yearLinks veriable. yearlinks veriable is not in any method

    – royal
    Nov 23 '18 at 6:50







    No sir. error is comming in the yearLinks veriable. yearlinks veriable is not in any method

    – royal
    Nov 23 '18 at 6:50















    updated the answer

    – Omair Shamshir
    Nov 23 '18 at 7:02





    updated the answer

    – Omair Shamshir
    Nov 23 '18 at 7:02













    Sir prob is not solve yet please guide. need to integrate my code to other code So..

    – royal
    Nov 23 '18 at 7:30







    Sir prob is not solve yet please guide. need to integrate my code to other code So..

    – royal
    Nov 23 '18 at 7:30















    I think the indentation of the code in your question doesn't match your real code. Until you fix that, we won't be able to help.

    – Matthias
    Nov 23 '18 at 8:40







    I think the indentation of the code in your question doesn't match your real code. Until you fix that, we won't be able to help.

    – Matthias
    Nov 23 '18 at 8:40















    0














    it's an unclear question. maybe staticmethod is what you wanted.



    class Data:
    def __init__(self):
    try: ------
    ----
    else:
    @staticmethod
    def link(url):

    all_links =
    page = requests.get(url)
    soup = BeautifulSoup(page.text, 'html.parser')
    for href in soup.find_all(class_='omrlist'):
    all_links.append(root_url + href.find('a').get('href'))
    return all_links
    yearLinks = Data.link(root_url + '/oilmarketreport/reports/')
    reportLinks =
    for url in yearLinks:
    links = Data.link(url)





    share|improve this answer
























    • yearLinks = Data.link(root_url + '/oilmarketreport/reports/') NameError: name 'Data' is not defined

      – royal
      Nov 23 '18 at 9:00













    • I need to integrate my to to other code So need to put all code in class and method format. during that got above error

      – royal
      Nov 23 '18 at 9:03











    • @royal can you check the indention? that's weird. you put code in a class.

      – Kevin Chan
      Nov 24 '18 at 13:24
















    0














    it's an unclear question. maybe staticmethod is what you wanted.



    class Data:
    def __init__(self):
    try: ------
    ----
    else:
    @staticmethod
    def link(url):

    all_links =
    page = requests.get(url)
    soup = BeautifulSoup(page.text, 'html.parser')
    for href in soup.find_all(class_='omrlist'):
    all_links.append(root_url + href.find('a').get('href'))
    return all_links
    yearLinks = Data.link(root_url + '/oilmarketreport/reports/')
    reportLinks =
    for url in yearLinks:
    links = Data.link(url)





    share|improve this answer
























    • yearLinks = Data.link(root_url + '/oilmarketreport/reports/') NameError: name 'Data' is not defined

      – royal
      Nov 23 '18 at 9:00













    • I need to integrate my to to other code So need to put all code in class and method format. during that got above error

      – royal
      Nov 23 '18 at 9:03











    • @royal can you check the indention? that's weird. you put code in a class.

      – Kevin Chan
      Nov 24 '18 at 13:24














    0












    0








    0







    it's an unclear question. maybe staticmethod is what you wanted.



    class Data:
    def __init__(self):
    try: ------
    ----
    else:
    @staticmethod
    def link(url):

    all_links =
    page = requests.get(url)
    soup = BeautifulSoup(page.text, 'html.parser')
    for href in soup.find_all(class_='omrlist'):
    all_links.append(root_url + href.find('a').get('href'))
    return all_links
    yearLinks = Data.link(root_url + '/oilmarketreport/reports/')
    reportLinks =
    for url in yearLinks:
    links = Data.link(url)





    share|improve this answer













    it's an unclear question. maybe staticmethod is what you wanted.



    class Data:
    def __init__(self):
    try: ------
    ----
    else:
    @staticmethod
    def link(url):

    all_links =
    page = requests.get(url)
    soup = BeautifulSoup(page.text, 'html.parser')
    for href in soup.find_all(class_='omrlist'):
    all_links.append(root_url + href.find('a').get('href'))
    return all_links
    yearLinks = Data.link(root_url + '/oilmarketreport/reports/')
    reportLinks =
    for url in yearLinks:
    links = Data.link(url)






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 23 '18 at 8:50









    Kevin ChanKevin Chan

    192




    192













    • yearLinks = Data.link(root_url + '/oilmarketreport/reports/') NameError: name 'Data' is not defined

      – royal
      Nov 23 '18 at 9:00













    • I need to integrate my to to other code So need to put all code in class and method format. during that got above error

      – royal
      Nov 23 '18 at 9:03











    • @royal can you check the indention? that's weird. you put code in a class.

      – Kevin Chan
      Nov 24 '18 at 13:24



















    • yearLinks = Data.link(root_url + '/oilmarketreport/reports/') NameError: name 'Data' is not defined

      – royal
      Nov 23 '18 at 9:00













    • I need to integrate my to to other code So need to put all code in class and method format. during that got above error

      – royal
      Nov 23 '18 at 9:03











    • @royal can you check the indention? that's weird. you put code in a class.

      – Kevin Chan
      Nov 24 '18 at 13:24

















    yearLinks = Data.link(root_url + '/oilmarketreport/reports/') NameError: name 'Data' is not defined

    – royal
    Nov 23 '18 at 9:00







    yearLinks = Data.link(root_url + '/oilmarketreport/reports/') NameError: name 'Data' is not defined

    – royal
    Nov 23 '18 at 9:00















    I need to integrate my to to other code So need to put all code in class and method format. during that got above error

    – royal
    Nov 23 '18 at 9:03





    I need to integrate my to to other code So need to put all code in class and method format. during that got above error

    – royal
    Nov 23 '18 at 9:03













    @royal can you check the indention? that's weird. you put code in a class.

    – Kevin Chan
    Nov 24 '18 at 13:24





    @royal can you check the indention? that's weird. you put code in a class.

    – Kevin Chan
    Nov 24 '18 at 13:24











    0














    Just for clearness:



    class Data:
    def __init__(self):
    """"""

    @staticmethod
    def link(url):
    return url


    print(Data.link("some_link")) # call method of class Data (will print "some_link")





    share|improve this answer




























      0














      Just for clearness:



      class Data:
      def __init__(self):
      """"""

      @staticmethod
      def link(url):
      return url


      print(Data.link("some_link")) # call method of class Data (will print "some_link")





      share|improve this answer


























        0












        0








        0







        Just for clearness:



        class Data:
        def __init__(self):
        """"""

        @staticmethod
        def link(url):
        return url


        print(Data.link("some_link")) # call method of class Data (will print "some_link")





        share|improve this answer













        Just for clearness:



        class Data:
        def __init__(self):
        """"""

        @staticmethod
        def link(url):
        return url


        print(Data.link("some_link")) # call method of class Data (will print "some_link")






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 9:17









        Andrey SuglobovAndrey Suglobov

        1549




        1549






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441308%2fhow-do-i-solve-missing-1-required-positional-argument%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]