IPython Tips and Tricks

Making the most of your interactive Python notebooks

Bryan White
The Startup

--

Photo by Dan Smedley on Unsplash

Documentation

Often times you will need to reference the documentation for a particular function or object that you are working with. Rather than having to use Google, you can directly access a function’s docstring from within your notebook using the shorthand ‘?’ command.
Example, if I were curious to know more about Python’s built in range() function I would write the below, which produces the following output:

Init signature: range(self, /, *args, **kwargs)
Docstring:
range(stop) -> range object
range(start, stop[, step]) -> range object

Return an object that produces a sequence of integers from start (inclusive)
to stop (exclusive) by step. range(i, j) produces i, i+1, i+2, ..., j-1.
start defaults to 0, and stop is omitted! range(4) produces 0, 1, 2, 3.
These are exactly the valid indices for a list of 4 elements.
When step is given, it specifies the increment (or decrement).
Type: type
Subclasses:

Tab Completion

When working with objects, it can be useful to use the Tab completion feature to not only save yourself some typing time, but it can also be used to show you all possible attributes for that object.
Example, if we were curious about all the…

--

--

Bryan White
The Startup

Supply Chain Analyst and Data Science Student at the University of Auckland.