CSPLang – Custom Syntax for Python Language
GITHUB: https://github.com/Ansari-Codes/custom-syntax-for-python
PYPI: https://pypi.org/project/csp-lang/
CSPLang is a high-speed, symbolic syntactic wrapper for Python. It transforms a compact, symbol-heavy DSL into executable Python code. Designed with the principle of "Write less, do more," CSPLang turns Python's keyword-heavy structure into a sleek, streamlined experience.
The CSPLang Philosophy: What if you had the full power of the Python ecosystem, but with the minimalist elegance of a functional language?
🚀 Key Features (v2.0)
- Recursive One-Liners: Define functions, loops, and conditions all on a single line.
- Context-Aware Parsing: Intelligently distinguishes between logic colons and data colons (like in dictionaries or list slices).
- Symbolic Identity: Replaces verbose keywords (
def,while,return) with intuitive symbols ($,>>,->). - Zero-Overhead Integration: Use any Python library (
numpy,tqdm,asyncio) out of the box.
🛠 Installation
Using git
# Clone and Install
git clone https://github.com/Ansari-Codes/custom-syntax-for-python.git
cd custom-syntax-for-python
pip install .
Using pip+git
pip install git+https://github.com/Ansari-Codes/custom-syntax-for-python.git
From pypi
pip install csp-lang
📝 Syntax Overview
1. Variables & Assignment
Use the "flow" operator <- for assignment.
name <- `Abubakar`
age <- 19
data <- [1, 2, 3]
2. Universal Strings
Forget f"", "", or ''' '''. Use backticks for everything. They support multiple lines and escaped backticks (`).
msg <- `This is a
multi-line string with a \`backtick\` inside.`
# F-strings work naturally:
print(f`Hello, {name}!`)
3. Conditionals (Implicit If)
No need to type if. A standalone condition ending in a colon is automatically treated as a conditional.
x <- 10
x > 5: # This is 'if'
print(`Large`)
: x == 5: # This is 'elif'
print(`Medium`)
: # This is 'else'
print(`Small`)
# NEW: One-liners are now supported!
x == 10: print(`Perfect Score`)
4. Loops
- While: Use
>> - For: Use
=>(where:replacesin)
# While Loop
count <- 3
>> count > 0:
print(count)
count <- count - 1
# For Loop
=> i:range(3):
print(f`Iteration {i}`)
5. Functions & Methods
Defined using $ and []. The -> symbol acts as the return.
# Standard definition
$add[a, b]:
-> a + b
# Works inside classes too!
class Math:
$cube[self, n]:
-> n ** 3
⚡ Extreme Flexibility (v2.0 Stress Test)
Because CSPLang v2.0 uses a Recursive Split Strategy, it can handle complex Python constructs mixed with CSP symbols without breaking.
# Slicing and Dictionaries work perfectly!
data <- [10, 20, 30, 40]
subset <- data[1:3] # Transpiler ignores the slice colon
results <- {`val`: subset[0]} # Transpiler ignores the dict colon
# Complex nesting and one-lining
$check[n]:
>> n > 0:
n%2==0:
print("Even: ", n)
:n%2!=0: print("Odd: ", n)
:print(n in [1, 2, 3, 4][:2])
n <- n - 1
check(10)
💻 CLI Usage
| Command | Description |
|---|---|
csp run file.csp |
Transpiles and executes immediately. |
csp transpile file.csp -o out.py |
Converts CSP to a standalone Python file. |
csp test |
Runs the internal test suite. |
Logo
Metadata
Release files for csp-lang 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| csp_lang-2.0.2.tar.gz | 10.7 kB | Without provenance | Details for csp_lang-2.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| csp_lang-2.0.2-py3-none-any.whl | Python 3 | none | any | Details for csp_lang-2.0.2-py3-none-any.whl |
Total release size: 22.2 kB
Release files / csp_lang-2.0.2.tar.gz
| Download URL | csp_lang-2.0.2.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
edbaf3f4d4dfbc016e41221028512cd83bfc989379c301e7452d136b093f56f7
|
|
BLAKE2b-256 checksum How to use checksums |
b0f008e11907a2bf568fab6f26872d8cac73a23abb2dc2bb12d78f5c225d8f23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / csp_lang-2.0.2-py3-none-any.whl
| Download URL | csp_lang-2.0.2-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
574a3aa731706dd8f294cecd798585602416cbcb5ae0da5eca58ae6985c1203d
|
|
BLAKE2b-256 checksum How to use checksums |
c30f86e998fb4c2677188651db754fe815b08764a36804fd0875ed4aead9e533
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Security for csp-lang 2.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.