How do you pass argument to functions in Python?
-
page = """ <div class="product-primarydata "> <p class="p product-price"> <span class="price-mrp"><del>Rs.100</del></span> <span class="price-fsp">Rs.58</span> </p> <div class="p"> <span class="rating-wrapper-big "> <span class="rating" style="width: 78%"></span> </span>1077 Ratings </div> """ def get_tag(self,start,end,page): start = page.find(start)+len(start) end = page[start:].find(end)+start return start,end first,last = get_tag('<span class="price-fsp">','</span>',page) but python shows: TypeError: get_tag() takes exactly 4 arguments (3 given) please find the error !!!!
-
Answer:
Is get_tag function part of a class ?. If not then just remove self from the function definition i.e. def get_tag(start,end,page): If get_tag is part of a class. The create instance of the class and use the instance to invoke get_tag. for e.g. class Tagging(object): def get_tag(self, start, end, page): # your code return tag aTag = Tagging() print aTag.get_tag() Also if you are new to python read up on Object Oriented Programming in Python to make sense of self keyword.
Ankur Gupta at Quora Visit the source
Related Q & A:
- How to access the Twitter Streaming API from Python?Best solution by Stack Overflow
- How can I call Android JavaScript functions in WebView?Best solution by Stack Overflow
- How to extract information from text file in Python?Best solution by Stack Overflow
- How to pass a C structure in Python?Best solution by Stack Overflow
- how can I write this shell script in python?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.