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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygolf-1.0.2.tar.gz
  • Upload date:
  • Size: 14.1 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.46.1 CPython/3.6.10

File hashes

Hashes for pygolf-1.0.2.tar.gz
Algorithm Hash digest
SHA256 60fff15944611d8d6818cabbb705e8481285a9b8e84fba4140ad053e0251ae24
MD5 aa85d3e1442035355d253eff1301871b
BLAKE2b-256 232f31a2a4fdbdbf5978328318f3f0dc9f60db9ce0c2af68ae3a4a772212c07d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygolf-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 19.3 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.46.1 CPython/3.6.10

File hashes

Hashes for pygolf-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7abf58912fd794454fac730954e1d1d22adb4c487572ac93f0d9db346c00526b
MD5 486ed12ce4a410d91a1e482b5c1adce9
BLAKE2b-256 756688dac6c3c5bd4c10ea971611a8bef6df2edf4d47e900af0e876e7d062351

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