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.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

pygolf-1.0.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file pygolf-1.0.0.tar.gz.

File metadata

  • Download URL: pygolf-1.0.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for pygolf-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1598db8fb376fb881254141a84a225e13b9ee8557adb83ef45e1a7241c85a9e6
MD5 2614ce36f78e632a134416567871a2c5
BLAKE2b-256 78e06446c45ebeda396cd027a1f1c9e9163beca89b122e1d49fba539e8539f70

See more details on using hashes here.

File details

Details for the file pygolf-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pygolf-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for pygolf-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c85a71d17f6a90cf8554294f1ef7a0dc1ea6fe04f45621d51aee5ea9e47d274
MD5 b0b3caba27619af3fe12b506aff7e934
BLAKE2b-256 967c4356619a48d93c1801741ab793db3bc66d57795fda643c032dbf311469c3

See more details on using hashes here.

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