Skip to main content

An automatic python code shortener

Project description

PyGolf

PyGolf is a python code shortener.

PyGolf takes a valid python code as input and outputs an equivalent code with fewer characters.

You can find examples of reduced code in the folder code_example. These examples mainly come from CodinGame's Clash of Code game.

Getting Started

Installing

You can install this project directly from pypi with pip install pygolf

How to use it

You can call it using either pygolf or python -m pygolf.

You can:

  • Give some code with -c, pygolf -c "print( 2 )"
  • Give an input and output file, pygolf -i input_file -o output_file
  • Shorten code in clipboard with pygolf -cb (usefull while doing a clash of code)

To modify the clipboard, pygolf requires pyperclip. You might have some issues such as Could not find a copy/paste mechanism for your system. If so, refer to pyperclip guidelines.

How does it work

PyGolf uses astroid to parse and apply transformations on the abstract syntax tree (AST).

PyGolf parses and unparses the AST several times through phases. Each phase comes with rules.

If you want to contribute, please refer to the CONTRIBUTING.md file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygolf-1.0.2.tar.gz (14.1 kB view hashes)

Uploaded Source

Built Distribution

pygolf-1.0.2-py3-none-any.whl (19.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page