Software & Apps

navxio/dopy: Python without strict indentation

An experimental Python preprocessor that enables do..end syntax in place of strict indentation

  • Converts to ruby/lua style do..end blocks to indented blocks
  • Continuing with python semantics
  • String literals and comments are preserved
  • Processes .dopy files into pep8 compliant .py files (maintaining dir structure)
  • supports type tips
  • Transpiles import simultaneously
from dopy.core import Dopy
dopy = Dopy()

source = '''
def hello_world() do
  print("Hello")
end
hello_world()
'''

processed = dopy.preprocess(source)
exec(processed, namespace={})

More examples of examples dir

dopy my_module.dopy

Use the currently active python interpreter, can be overridden by PYTHON_PATH env before

-h,--help: Print help text

-k,--keep: Keep transpiled python files in place (overwrite)

-s,--stdout: Print the transpiled python code to console and exit

-c,--check: Check dopy syntax without transpiling

  • Make sure the do keyword is on the same line as the rest of the block declaration,
  • end should be on its own line
  • all import above module
  • must make and __init__.py dirs file to identify the transpiled python modules
  • Keep imports relative to the directory structure, just like regular Python

This project is very inspiring mathialo/bython

See LICENSE

I built it to learn more about python/interpreter language syntax in general, but am not interested in continuing with it.


https://opengraph.githubassets.com/c84ae711972c4d07df4bceeb60215951f540a7873f0f16b2bb8a82bccc229c9d/navxio/dopy

2025-01-10 13:53:00

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button