[Python Tips] Getting Help

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@themarkymark·
0.000 HBD
[Python Tips] Getting Help
![](https://steemitimages.com/DQmSsFP8BDE1DkXNN9hh1729MRexyqupLEKfWJTsRskjt33/image.png)

There are a few handy functions built into Python to help the developer get more information about an object.

# help()

If you want to get the documentation on an object or function you can use the help() function to look up any documentation available.

```
> help(id)
Help on built-in function id in module builtins:
>>> 
id(obj, /)
    Return the identity of an object.  
    This is guaranteed to be unique among simultaneously existing objects.
    (CPython uses the object's memory address.)
```

This is only useful when using python interactively via **repl** or [bpython](https://steemit.com/programming/@themarkymark/python-tips-a-better-interactive-shell).


# dir()

When you call dir() without any arguments, it will return the names of everything in scope.

```
>>> dir()
['__builtins__', '__doc__', '__name__', 'help']
>>> a = 5
>>> dir()
['__builtins__', '__doc__', '__name__', 'a', 'help']
```

If you call dir on an object, it will return all the available attributes.

```
>>> a = 'Hello World'
>>> dir(a)
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init
_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__',
 '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', '
islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 
'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
```

dir() is also most useful when using python interactively.

While both of these functions are not typically used on a daily basis, knowing they are available can be helpful when working interactively.  I typically work interactively when doing querying or working with objects I don't understand yet to get a feel for how they work.  This is where [bypython](https://steemit.com/programming/@themarkymark/python-tips-a-better-interactive-shell) shines.

As always, the [Python Online Docs](https://docs.python.org/3/) is a great reference when trying to understand how the built-in functions and objects work.  They can be difficult to understand to new programmers and just doing a Google search for what you need help with and then clicking videos usually yields the best results.  Almost every topic has been covered in detail in a YouTube video.

# Good Python YouTubers I highly recommend.

* [Sentdex](https://www.youtube.com/user/sentdex)
* [Dan Bader](https://www.youtube.com/channel/UCI0vQvr9aFn27yR6Ej6n5UA)
* [Data School (Kevin Markham)](https://www.youtube.com/channel/UCnVzApLJE2ljPZSeQylSEyg)
* [Derek Banas](https://www.youtube.com/user/derekbanas/featured)

If you haven't already, consider opening an account on [StackOverflow](https://stackoverflow.com) the most popular Q&A site for developers across the world.

# My Python Tips Series

* [f-strings in Python 3.6](https://steemit.com/programming/@themarkymark/python-tips-f-strings-in-python-3-6-and-why-you-should-be-using-them)
* [Underscores in numeric literals](https://steemit.com/programming/@themarkymark/python-tips-underscores-in-numeric-literals)
* [A better interactive shell](https://steemit.com/programming/@themarkymark/python-tips-a-better-interactive-shell)
* [Secrets Module - New in 3.6](https://steemit.com/programming/@themarkymark/python-tips-secrets-module-new-in-3-6)
* [PEP 8](https://steemit.com/programming/@themarkymark/python-tips-pep-8)
* [Slices](https://steemit.com/programming/@themarkymark/python-tips-slices)
* [Named Tuples](https://steemit.com/programming/@themarkymark/python-tips-named-tuples)
* [Destructuring](https://steemit.com/programming/@themarkymark/python-tips-destructuring)
* [Counter](https://steemit.com/programming/@themarkymark/python-tips-counter)
* [Type Annotation](https://steemit.com/programming/@themarkymark/python-tips-type-annotation)
* [Jupyter Notebooks](https://steemit.com/programming/@themarkymark/python-tips-jupyter-notebooks)


<center><sub><sub> X48EJ </sub></sub></center>

# <center>  [Why you should vote me as witness](https://steemit.com/witness-category/@themarkymark/why-you-should-vote-for-themarkymark-as-witness)  </center> #
<center>https://steemitimages.com/DQmcWxV1dpA1eAtw2ipwZiWZkydyVNU5LaLa2Ak1GUnbGmS/The-Marky-Mark.png </center>

# <center> Witness & Administrator of four full nodes </center> #

![themarkymark.png](https://steemitimages.com/DQmVpwMxWTYDVum2dXcVRBLwHqHZh2Sr6DDHAFwDeeTG2YK/themarkymark.png)


</br>

# <center> My recent popular posts </center> #

[STEEM, STEEM Power, Vests, and Steem Dollars. wtf is this shit?](https://steemit.com/steem/@themarkymark/steem-steem-power-vests-and-steem-dollars-wtf-is-this-shit)
[The truth and lies about 25% curation, why what you know is FAKE NEWS](https://steemit.com/curation/@themarkymark/the-truth-and-lies-about-25-curation-why-what-you-know-is-fake-news)
[WTF is a hardware wallet, and why should you have one?](https://steemit.com/bitcoin/@themarkymark/wtf-is-a-hardware-wallet-and-why-should-you-have-one)
[GINABOT - The Secret to your Sanity on Steemit](https://steemit.com/ginabot/@themarkymark/ginabot-the-secret-to-your-sanity-on-steemit)
[How to calculate post rewards](https://steemit.com/steemit/@themarkymark/how-to-calculate-post-rewards)
[Use SSH all the time? Time for a big boy SSH Client](https://steemit.com/linux/@themarkymark/use-ssh-all-the-time-time-for-a-big-boy-ssh-client)
[How to change your recovery account](https://steemit.com/steemit/@themarkymark/how-to-change-your-recovery-account)
[How curation rewards work and how to be a kick ass curator](https://steemit.com/curation/@themarkymark/how-curation-rewards-work-and-how-to-be-a-kick-ass-curator)
[Markdown 101 - How to make kick ass posts on Steemit](https://steemit.com/steemit/@themarkymark/markdown-101-how-to-make-kick-ass-posts-on-steemit)
[Work ON your business, not in your business! - How to succeed as a small business](https://steemit.com/business/@themarkymark/work-on-your-business-not-in-your-business-how-to-succeed-as-a-small-business)
[You are not entitled to an audience, you need to earn it!](https://steemit.com/steemit/@themarkymark/you-are-not-entitled-to-an-audience-you-need-to-earn-it)
[How to properly setup SSH Key Authentication - If you are logging into your server with root, you are doing it wrong!](https://steemit.com/sysadmin/@themarkymark/how-to-properly-setup-ssh-key-authentication-if-you-are-logging-into-your-server-with-root-you-are-doing-it-wrong)
[Building a Portable Game Console](https://steemit.com/raspberrypi/@themarkymark/building-a-portable-game-console)

[![](https://steemitimages.com/DQmPkQhAQceC7aHr4Gy5GKv7LMoiy47P7PyaNCeZBHMpFke/white-bg-with-drop-shadow.gif)](https://v2.steemconnect.com/sign/account-witness-vote?witness=themarkymark&approve=1) 
👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,