From 4070fe73f197a63fb6c37c0481e6b39d6e371819 Mon Sep 17 00:00:00 2001 From: Chris Baker Date: Tue, 4 Sep 2018 16:01:46 -0400 Subject: [PATCH] update readme --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fcb516e..4c9b93b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![PyPI version](https://img.shields.io/pypi/v/reprexpy.svg)](https://pypi.org/project/reprexpy/) [![Python versions](https://img.shields.io/pypi/pyversions/reprexpy.svg)](https://pypi.org/project/reprexpy/) -`reprexpy` is a Python package that renders **repr**oducible **ex**amples (also known as [reprexes](https://twitter.com/romain_francois/status/530011023743655936) or [minimal working examples (MWEs)](https://en.wikipedia.org/wiki/Minimal_Working_Example)) so that they are ready to be posted to GitHub or Stack Overflow. It is a port of the R package [reprex](https://github.com/tidyverse/reprex). +`reprexpy` is a Python package that renders **repr**oducible **ex**amples (also known as [reprexes](https://twitter.com/romain_francois/status/530011023743655936) or [minimal working examples (MWEs)](https://en.wikipedia.org/wiki/Minimal_Working_Example)) to a format suitable for posting to GitHub or Stack Overflow. It's a port of the R package [reprex](https://github.com/tidyverse/reprex). ## Installation @@ -24,7 +24,7 @@ pip install git+https://github.com/crew102/reprexpy.git ## A basic example -Let's say you want to know if there's a shortcut for flatting lists in Python, so you create the following MWE to post to SO (example inspired by [this SO question](https://stackoverflow.com/questions/952914/making-a-flat-list-out-of-list-of-lists-in-python)): +Let's say you want to know if there's a shortcut for flatting lists in Python, so you create the following MWE to post to SO (MWE inspired by [this SO question](https://stackoverflow.com/questions/952914/making-a-flat-list-out-of-list-of-lists-in-python)): ```python # i know that you can flatten a list in python using list comprehension: @@ -36,7 +36,7 @@ import functools functools.reduce(lambda x, y: x.extend(y), l) ``` -You'd like to put the outputs of running the above code into the example itself, to show people what you are seeing in your terminal: +You'd like to include the outputs of running the above code into the example itself, to show people what you're seeing in your terminal: ```python # i know that you can flatten a list in python using list comprehension: @@ -53,11 +53,11 @@ functools.reduce(lambda x, y: x.extend(y), l) #> AttributeError: 'NoneType' object has no attribute 'extend' ``` -You could run the code in your terminal and copy/paste the outputs into your example. That can be a pain, though, especially if you have a lot of outputs to copy. An easier way to include the outputs is to use `reprex()`: +You could run the code in your terminal and copy/paste the outputs into your example. That can be a pain, though, especially if you have a lot of outputs to copy. An easier way is to use `reprex()`: ![](https://raw.githubusercontent.com/crew102/reprexpy/master/docs/source/gifs/basic-example.gif) -When you run `reprex()`, your code is run inside an IPython kernel and the outputs (including errors) are captured and displayed alongside the code. Details on the IPython session are given as well in a section called "Session Info" (more on this later). +When you run `reprex()`, your MWE is run inside an IPython kernel. The outputs from running your code (including errors) are captured and displayed alongside the code itself. Details on the IPython session are also given at the end of your example by calling `SessionInfo()` (more on this later). ## Including `matplotlib` plots @@ -81,13 +81,13 @@ plt.show() plt.close() ``` -You can render this reprex to a format suitable for posting to GitHub using `reprex()`: +You can prepare this reprex for posting to GitHub using `reprex()`: ![](https://raw.githubusercontent.com/crew102/reprexpy/master/docs/source/gifs/plotting.gif) ## `SessionInfo()` -You may have noticed in the previous two examples that a section called "Session Info" is added to the end of your reprex. This section includes details about the IPython kernel that was used to render your reprex, such as the Python version that was used and the platform the code was run on, as well as the version numbers of the packages used in your example (e.g., `matplotlib`). You can use the `SessionInfo()` function to get this information whenever you are using an IPython kernel (e.g., when you are inside an IPython terminal or Jupyter notebook): +You may have noticed in the previous two examples that a section called "Session info" is added to the end of your reprex by default. This section uses the `SessionInfo()` function to include details about the IPython kernel that was used to run your reprex, as well as what the version numbers are of any relevant third-party packages. Note that you can call `SessionInfo()` outside of reprexes, so long as you're using an IPython kernel (e.g., when inside an IPython terminal or Jupyter notebook): ```python import pandas