{ "info": { "author": "Christopher Baker", "author_email": "chriscrewbaker@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "# reprexpy\n\n> Render **repr**oducible **ex**amples of Python code for posting to GitHub/Stack Overflow (port of R package `reprex`)\n\n[![Linux Build Status](https://travis-ci.org/crew102/reprexpy.svg?branch=master)](https://travis-ci.org/crew102/reprexpy)\n[![PyPI version](https://img.shields.io/pypi/v/reprexpy.svg)](https://pypi.org/project/reprexpy/)\n[![Python versions](https://img.shields.io/pypi/pyversions/reprexpy.svg)](https://pypi.org/project/reprexpy/)\n\n`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).\n\n## Installation\n\nYou can get the stable version from PyPI:\n\n```\npip install reprexpy\n```\n\nOr the development version from GitHub:\n\n```\npip install git+https://github.com/crew102/reprexpy.git\n```\n\n## A basic example\n\nLet'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)):\n\n```python\n# i know that you can flatten a list in python using list comprehension:\nl = [[1, 2, 3], [4, 5, 6], [7], [8, 9]]\n[item for sublist in l for item in sublist]\n\n# but i'd like to know if there's another way. i tried this but i got an error:\nimport functools\nfunctools.reduce(lambda x, y: x.extend(y), l)\n```\n\nYou'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:\n\n```python\n# i know that you can flatten a list in python using list comprehension:\nl = [[1, 2, 3], [4, 5, 6], [7], [8, 9]]\n[item for sublist in l for item in sublist]\n#> [1, 2, 3, 4, 5, 6, 7, 8, 9]\n\n# but i'd like to know if there's another way. i tried this but i got an error:\nimport functools\nfunctools.reduce(lambda x, y: x.extend(y), l)\n#> Traceback (most recent call last):\n#> File \"\", line 1, in \n#> File \"\", line 1, in \n#> AttributeError: 'NoneType' object has no attribute 'extend'\n```\n\nYou 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()`:\n\n![](https://raw.githubusercontent.com/crew102/reprexpy/master/docs/source/gifs/basic-example.gif)\n\nWhen 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).\n\n## Including `matplotlib` plots\n\n`reprex()` makes it easy to include `matplotlib` plots in your reprexes. It does this by uploading the plots to imgur and including inline links to them in your example. For example, let's say you have the following MWE that you want to post to GitHub:\n\n```python\nimport matplotlib.pyplot as plt\n\ndata = [1, 2, 3, 4]\n\n# i'm creating a plot here\nplt.plot(data);\nplt.ylabel('some numbers');\nplt.show()\nplt.close()\n\n# another plot\nplt.plot(data);\nplt.xlabel('more numbers');\nplt.show()\nplt.close()\n```\n\nYou can prepare this reprex for posting to GitHub using `reprex()`:\n\n![](https://raw.githubusercontent.com/crew102/reprexpy/master/docs/source/gifs/plotting.gif)\n\n## Render Sphinx code examples\n\nCreating code examples to insert into Sphinx docs is a breeze with `reprex()`. For example, let's say you want to include an example for the following function:\n\n```python\ndef are_dogs_awesome():\n r\"\"\"Are dogs awesome?\n\n Examples\n --------\n\n\n \"\"\"\n return 'Yep'\n```\n\nJust `reprex()` your example and paste the result into your docstring:\n\n![](https://raw.githubusercontent.com/crew102/reprexpy/master/docs/source/gifs/sphinx.gif)\n\n## `SessionInfo()`\n\nYou may have noticed in the previous two examples that a section called \"Session info\" is added to the end of your reprex by default (note, this is no longer the case in version 0.2.0 and above). 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):\n\n```python\nimport pandas\nimport requests\nimport numpy\n\nfrom reprexpy import SessionInfo\nSessionInfo()\n#> Session info --------------------------------------------------------------------\n#> Date: 2018-08-27\n#> Platform: Darwin-17.7.0-x86_64-i386-64bit (64-bit)\n#> Python: 3.5\n#> Packages ------------------------------------------------------------------------\n#> numpy==1.15.0\n#> pandas==0.23.4\n#> reprexpy==0.1.0\n#> requests==2.19.1\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://reprexpy.readthedocs.io/en/latest", "keywords": "", "license": "LICENSE.txt", "maintainer": "", "maintainer_email": "", "name": "reprexpy", "package_url": "https://pypi.org/project/reprexpy/", "platform": "", "project_url": "https://pypi.org/project/reprexpy/", "project_urls": { "Homepage": "https://reprexpy.readthedocs.io/en/latest" }, "release_url": "https://pypi.org/project/reprexpy/0.3.0/", "requires_dist": [ "pyperclip", "asttokens", "nbconvert", "nbformat", "matplotlib", "ipython", "pyimgur", "setuptools", "stdlib-list", "ipykernel", "tornado (<=5.1.1)" ], "requires_python": "", "summary": "Render reproducible examples of Python code (port of R package `reprex`)", "version": "0.3.0" }, "last_serial": 4695647, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "a3d045d0470c618bf5089528d7661146", "sha256": "a4e92f02c23346126816e62e665b7678ede8a092c8dc9484d6c045f07ba72151" }, "downloads": -1, "filename": "reprexpy-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a3d045d0470c618bf5089528d7661146", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12715, "upload_time": "2018-08-27T19:25:39", "url": "https://files.pythonhosted.org/packages/6e/07/1534b5ac14d1d7d3e8895aa3b756046dbdc546704eb2dccb14fd0cfbc413/reprexpy-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c2d92270acfee9fd13bd6750120cf581", "sha256": "2a0f07efcb2c4a38a45b952ec288a42c77ae95718b17e4a3eccffdc4df674dd2" }, "downloads": -1, "filename": "reprexpy-0.1.0.tar.gz", "has_sig": false, "md5_digest": "c2d92270acfee9fd13bd6750120cf581", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13101, "upload_time": "2018-08-27T19:25:40", "url": "https://files.pythonhosted.org/packages/f3/47/7f4b858214572569d1e086835052010a11e52d783ebbbe12da6474e128e8/reprexpy-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "7794f62b7fb7ead82a55b29c4009a6a4", "sha256": "351964ab7d8a52fd07568da0faee279b67c206cdbc31730cd4e8715c04a76d56" }, "downloads": -1, "filename": "reprexpy-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7794f62b7fb7ead82a55b29c4009a6a4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12727, "upload_time": "2018-08-30T19:05:46", "url": "https://files.pythonhosted.org/packages/6a/8d/3365fe2e3f8521f697d5bd38b6eba9b9f3a229428472eb8ed8836d09e8db/reprexpy-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1ba736ddf4ecc3a9ee4ad0e4612e1e4e", "sha256": "e7daae3ac81822e6bdf994399c03863310bc0cfef9b75b21ae8efc33d8e794b6" }, "downloads": -1, "filename": "reprexpy-0.1.1.tar.gz", "has_sig": false, "md5_digest": "1ba736ddf4ecc3a9ee4ad0e4612e1e4e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13249, "upload_time": "2018-08-30T19:05:48", "url": "https://files.pythonhosted.org/packages/06/7a/6aa6f98fa99702b1c1b41927e204bc6241ade7215a428759fe58671401be/reprexpy-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "65786bf465a9ded8ef13844af36fa243", "sha256": "c5574ddd2c43a300a4f4750a0e8a21593ff337dd70a4b4c90c1fa45abc4380ec" }, "downloads": -1, "filename": "reprexpy-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "65786bf465a9ded8ef13844af36fa243", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12756, "upload_time": "2018-10-25T15:33:37", "url": "https://files.pythonhosted.org/packages/52/b9/e644600364c51531d7d8fa6ce60cda8e519a47027e850a029d496b8dc88c/reprexpy-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f964953575b92138a4604b07b422d5be", "sha256": "0f466e8cbf613df8def00a092813134f7bb0d82a8a3a855a87e44961ff75306c" }, "downloads": -1, "filename": "reprexpy-0.2.0.tar.gz", "has_sig": false, "md5_digest": "f964953575b92138a4604b07b422d5be", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13332, "upload_time": "2018-10-25T15:33:39", "url": "https://files.pythonhosted.org/packages/42/97/01ac11eef816a60619e09aad156da721f4444667f8f5589c10668a82d328/reprexpy-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "4b3c7db195dd702a2c0d45cfc9c040f2", "sha256": "122a20a4ab115df8019b9a7e2b5d6113464888e189f2b2082697a65022ddf102" }, "downloads": -1, "filename": "reprexpy-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4b3c7db195dd702a2c0d45cfc9c040f2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12819, "upload_time": "2018-10-25T16:02:50", "url": "https://files.pythonhosted.org/packages/b2/f3/963af4ed751e7d3d49c90109bca3b43294fe3e2eb84360c1ae4acc7bb15f/reprexpy-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "15b56c8ef2ebdc308b2919fc4c0a8fca", "sha256": "39680f394421a40663cda65769b9f8b43a1289058843e689f7524f8b65d45717" }, "downloads": -1, "filename": "reprexpy-0.2.1.tar.gz", "has_sig": false, "md5_digest": "15b56c8ef2ebdc308b2919fc4c0a8fca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13373, "upload_time": "2018-10-25T16:02:51", "url": "https://files.pythonhosted.org/packages/e7/96/4ef232cba15bb526279a8d6af22dc3e2f9646a7feee6871b67ab512dbb19/reprexpy-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "87f69ac5ba005e69904f0ee6ed99b844", "sha256": "e611071052b5345ce5722e87b0c9e8a7653d95576312ed642710fba60855986f" }, "downloads": -1, "filename": "reprexpy-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "87f69ac5ba005e69904f0ee6ed99b844", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13363, "upload_time": "2019-01-14T20:05:12", "url": "https://files.pythonhosted.org/packages/e8/a8/45f6ae266b338344b36cca3a2bb902d01cccb82398c0907335dccf2049b8/reprexpy-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "31f903db5c929a3986559c04f52fcc61", "sha256": "847dd3a6584b26c8f02f5a61f23b3d548d745a56da4ad6788c1e3129a8a0d6ca" }, "downloads": -1, "filename": "reprexpy-0.3.0.tar.gz", "has_sig": false, "md5_digest": "31f903db5c929a3986559c04f52fcc61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14157, "upload_time": "2019-01-14T20:05:13", "url": "https://files.pythonhosted.org/packages/cb/9c/ff65579bb76159745537382f413c4ad5d5442adb1e65f6c0bc8ce8ea8c14/reprexpy-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "87f69ac5ba005e69904f0ee6ed99b844", "sha256": "e611071052b5345ce5722e87b0c9e8a7653d95576312ed642710fba60855986f" }, "downloads": -1, "filename": "reprexpy-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "87f69ac5ba005e69904f0ee6ed99b844", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13363, "upload_time": "2019-01-14T20:05:12", "url": "https://files.pythonhosted.org/packages/e8/a8/45f6ae266b338344b36cca3a2bb902d01cccb82398c0907335dccf2049b8/reprexpy-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "31f903db5c929a3986559c04f52fcc61", "sha256": "847dd3a6584b26c8f02f5a61f23b3d548d745a56da4ad6788c1e3129a8a0d6ca" }, "downloads": -1, "filename": "reprexpy-0.3.0.tar.gz", "has_sig": false, "md5_digest": "31f903db5c929a3986559c04f52fcc61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14157, "upload_time": "2019-01-14T20:05:13", "url": "https://files.pythonhosted.org/packages/cb/9c/ff65579bb76159745537382f413c4ad5d5442adb1e65f6c0bc8ce8ea8c14/reprexpy-0.3.0.tar.gz" } ] }