Skip to content MY

Your Best Friend Before Google in Python! 👩‍💻

women sitting on rock near body of water
Picture by Roberto Nickson on Unsplash

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:

Screenshot from 2021-01-29 13-05-49.png

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!

Stay connected

Stay updated with what I'm tinkering with. Follow me on Twitter to connect, ask a question, or chat!

Follow me