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!
Release files for colonpython 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| colonpython-0.0.3.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| colonpython-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.0 kB
Release files / colonpython-0.0.3.tar.gz
| Download URL | colonpython-0.0.3.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4cc065a7201453ce5826a442479598220f3f780b0b80c6f288e64c429377fea
|
|
BLAKE2b-256 checksum How to use checksums |
d33093dd914d66201b8c500944411a0e265736b52533240c3c53700d616226fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / colonpython-0.0.3-py3-none-any.whl
| Download URL | colonpython-0.0.3-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d87cff60f397ebd2b90c2565a0b65bb375b61cec064ca99570b9f44efb36071d
|
|
BLAKE2b-256 checksum How to use checksums |
202a823f4aa133c66cf32af65f0352c862a60600e7268c9f026c03b5e9cb8911
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|