-3

What is the optimal way to get documentation about a specific function in Python? I am trying to download stock price data such that I can view it in my Spyder IDE.

The function I am interested in is:

ystockquote.get_historical_prices

How do I know how many inputs the function takes, the types of inputs it accepts, and the date format for example?

4
  • 2
    Did you try using Python's help function on the function you need help with? You can use the help method in interactive mode or you can print out the results if you're running in an IDE. Commented Feb 2, 2016 at 1:20
  • I am sorry I am new. How do I use Python's help function? Commented Feb 2, 2016 at 1:27
  • 2
    It's a method. You just give help parameters, such as a function: help(ystockquote.get_historical_prices). You can also try googling: pypi.python.org/pypi/ystockquote Commented Feb 2, 2016 at 1:29
  • @Shaymin Actually, it's an instance of the site._Helper class. Commented Feb 2, 2016 at 2:42

1 Answer 1

1

Just finding documentation

I suspect this question was super-downvoted because the obvious answer is to look at the documentation. It depends where your function came from, but googling is typically a good way to find it (I found the class here in a few seconds of googling).

It is also very trivialy to just check the source code

In order to import a function, you need to know where the source file it comes from is; open that file: in python, docstrings are what generate the documentation and can be found in triple-quotes beneath the function declaration. The arguments can be inferred from the function signature, but because python is dynamically typed, any type "requirements" are just suggestions. Some good documenters will provide the optimal types, too.

While "how do I google for documentation" is not a suitable question, the question of how to dynamically infer documentation is more reasonable. The answer is

  1. The help function, built in here
  2. The file __doc__ accessible on any python object, as a string
  3. Using inspection

The question is even more reasonable if you are working with python extensions, like from external packages. I don't if the package you specifically asked about has any of those, but they can be tricky to work with if the authors haven't defined docstrings in the module. The problem is that in these cases, the typing can be rigidly inforced. There is no great way to get the tpye requirements in this case, as inspection will fail. If you can get at the source code, though, (perhaps by googling), this is where the documentation would be provided

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.