Skip to main content

A programming language that transpiles to python and centres around colons (hence the name).

Project description

ColonPython

A programming language that transpiles to python. It has extremely similar syntax, but you are also able to call functions with only one argument using a colon (:) using the following syntax:

function:argument

This allows for statements such as this in ColonPython:

print:"hello"

or:

str:1234

It allows you to call single-argument functions whilst shortening the time it takes to write them.

To use ColonPython, first install it using:

pip3 install colonpython

Then, to use it in your program, create a new python file and before putting in any code write:

import colonpython

Please note that sometimes Python will detect what it thinks are syntax errors, even though the code will run. This means that some things are not possible. This problem has caused this project to split into two. ColonPython and ArrowPython. ColonPython is this project: adding a way to call functions with an argument using a colon (:), and is used by importing the module and running the code in the file. As python identifies incorrect python syntax before runtime and raises errors, ArrowPython intead lets you run code on external files. It has more non-Python features. If I could use them in the same was as ColonPython, I would, but I cannot as far as I am aware.

Sometimes, you may run into issues. The following code will run fine:

indexes = ("hello", "world")

print(indexes[0:1]) # This returns the string "hello".

However, the following code will not:

indexes = ("hello", "world")

start = 0
end = 1

print(indexes[start:end]) # Raises error.

Because of this I would reccomend the following:

indexes = ("hello", "world")

start = 0
end = 1

print(indexes[slice(start:end)]) # Does not raise an error, returns the string "hello".

Another issue comes to light when you try to try to use type hints. The following code is valid in standard python:

def greeting(name: str) -> str:
    return 'Hello ' + name

However, in ColonPython it is not, as this would treat the variable "name" as a function. In ColonPython you must declare type hints using the following syntax:

hint(variable, type)

Therefore, the following code is valid in ColonPython:

def greeting(hint(name, str)) -> str:
    return 'Hello ' + name

With that out of the way, this is an example of the popular FizzBuzz program in ColonPython:

import colonpython

def fizbuzz:num:
    for fizzbuzz in range:num:
        if fizzbuzz % 3 == 0 and fizzbuzz % 5 == 0:
            print:"fizzbuzz"
            continue
        elif fizzbuzz % 3 == 0:
            print:"fizz"
            continue
        elif fizzbuzz % 5 == 0:
            print:"buzz"
            continue
        print:fizzbuzz

fizbuzz:51

Have fun coding!

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

colonpython-0.0.3.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

colonpython-0.0.3-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

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