Installing ASnake

ASnake Documentation

Table Of Contents

Pip Install:

Assuming that you have installed Python, and ensured that you have pip or some alternative to install ASnake from PyPi (Python Package Index), you can begin installing ASnake.

By now you should know what alias to call Python with in the terminal. py for Windows, python3 for Ubuntu, python for Arch, etc. This guide will be using python, but replace with the command relevant to your system.

console
python -m pip install ASnake

pip install ASnake

You should see something similar to the above image.

To check if ASnake works, we will be printing out the number 12.

Enter this: python -m ASnake -e "12"

pip install ASnake

If it prints out code and 12, then congrats! ASnake is installed!

Run ASnake File:

Next, let's make a ASnake file and run it. Make a text file (you do know how to do that, right?) and name it with the .asnake extension, though that is technically optional.

For now, just enter something simple like:

"hello world!"
2 + 2

Navigate to the directory containing your file in the terminal (or write the path to it), and assuming you named the file myCode enter this:

python -m ASnake -r myCode.asnake

The -r (which is called a compiler flag) stands for 'run'. You should get this result in the eval:

console
hello world!
4

If you want to learn more about what compiler flags ASnake's compiler has, enter the command python -m ASnake --help

Optimize A Python Code:

Some of you are only here to steal ASnake's optimizations and not to use the language. This section is for you.

Keep in mind optimizations are on by default for both ASnake and Python code, you can turn it off by using the -o (optimization) compiler flag.

ASnake is not an exact superset of Python, it is a semi-superset. However, you can force it to be a full-superset by using the Python compatibility compiler flag:

python -m ASnake -pc -c myPythonFile.py

The -pc stands for python-compatibility, and -c stands for compile, which makes a new file with the optimized code. The -c flag will do the same thing when not in Python mode, it outputs a compiled Python file.

You will get something like: myPythonFile.py compiled to AS_myPythonFile.py

Once compiled can run it like a normal Python file: python AS_myPythonFile.py

Or just add the -r flag to the initial command to run the file right after compilation.

Setting Up ASnake Alias:

So using python -m ASnake is kinda annoying to type out right? You can set up an alias for it in the terminal so you only have to type ASnake!

If you are on Windows, you likely use PowerShell or cmd. If you are Linux, you likely use bash, zsh, or fish. If that is true, then ASnake can set up the alias for you!

Run this command to automatically set up your aliases:

python -m ASnake -as setAlias

For now this doesn't handle PyPy or Pyston, hope you are okay with that.

To test to see if it worked, do:

ASnake -e "12"
Scroll to top