It is no secret (or so I hope) that when programming in any given language, consulting the official documentation (as most of them are up-to-date, extensively detailed and thorough) is crucial to understanding the intricacies and details of the technology we're fiddling with.
But sometimes, we find ourselves wasting a lot of time looking for something very specific due to the disorganization of the documentation. Luckily enough, we have a generous method at our proposal, which is the help() method
Allow me to introduce you to your best friend
help() is a method (function) that invokes a built-in help system which displays official and brief documentation of:
Modules
Classes (user-defined or built-in)
Methods (user-defined or built-in)
Keywords
Oh and by the way, if you want to display all Python's keywords:
from keyword import kwlist
print(kwlist)
The method takes in an object as parameter help(object):
help(str)
help(int)
help(help)
#I know some of you like myself would attempt this haha
#It is a valid statement
So how do I use it?
There are two ways to use this method:
By passing an argument: as we did in the previous example above.
Without arguments: which starts an interactive help system on the interpreter's console:
Why should I care?
If you want a brief, concise and official description or documentation about a certain object without going through the lengthy one available online, or if you want to quickly glance over or discover the different methods that can be used on an object, or if you don't have an internet connection available at a given time, help() is your go to!
The End!
I hope you enjoyed reading this! Let me know how you find this type of short articles!
Any feedback or constructive critique is warmly welcomed and appreciated, so please tell me what you think in the comments so I can better the quality. Thanks for reading โค๏ธ!
Follow me on Twitter for more!
Photo by Chris Ried on Unsplash