Date Subject Software System
11th April 2021 Python Hack Python3.7 and Notepad++ Windows 7

Introduction to Pythonen

How to hack python to use a keyword instead of white space for code structure.

Description

When I started using python, I disliked the use of white space indentation to denote code structure so much that I decided to try to hack python to override this feature.

I managed to hack python so that I can use 'end' keywords (like Matlab) to denote the end of loops and code structures. I do this by intercepting the decoded file before it goes to the interpreter.

The video below shows how I did this and the scripts are available from the link at the bottom of the page.

Warning!! This is a hack that I just did for fun (although I do program in pythonen now!).

There are some rules to follow if you really want to use this.

1. 'end' becomes a reserved keyword, so shouldn't be used for variable names, etc.

2. Some scripts don't deal with continuation lines unless you use a backslash to denote the continuation.

3. You need to auto-indent your pythonen code before running it, however, it is also possible to include the auto-indent script in the encoding file, in which case you can have your code indented however you like in pythonen.

No warranty given. Use at your own risk.

I might look into modifying cpython to make a proper pythonen interpreter.

Leave a Comment on this Article

Feel free to leave a comment or question. Include your email address if you want a private answer (email will not be shown). It takes a little while for the comment to appear as our AI bot checks for offensive or inappropriate comments!

We reserve the right to edit comments to remove unsuitable content.

Screen Name (displayed):
Email (not displayed):
Comment (<500 characters):

Downloads

pythonen1.zip