Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
crew102 committed Sep 10, 2018
1 parent c0fdce9 commit 4070fe7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 4070fe7

Please sign in to comment.