Skip to main content

Use c-style braces instead of indentation. This is an encoding, you can also import this module in sites.py, it will register the encoding on import.

to use this, add the magic encoding comment to your source file:

# coding: cstyle

Then you can import it to run it. or if you added the encoding to your sites.py, you can use idle to view the decoded file. Use notepad++ or the editor of your choice. Do not use this. DO NOT USE THIS. and do not use this. this works, but this is not a good idea.

Currently just works for “if|elif|else|for|while|def|with” statements. do not mix indentation and braces. you can do that, but it is not recommended. Treat this module just as a toy, or if you have any special purpose to use it. This program is open source, lgpl, you can edit or use it for free.

One usage for this module can be reducing source code size (compressing).

You can also decode cstyle literals:

import cstyle
    a = b'cstyle code'
    a.decode('cstyle')

To know how to code with cstyle examine the examples provided here. This is not an alpha release, this is not a beta release, this is not a release at all. this is not a real program, at least at this point. use for educational purposes or whatever. There’s no warranty. There might be parsing errors, it is tested on the code provided in the examples here.

What this can do?

This will convert:

if(1 in {1,2,3}){
    print(5)
    for(x in c){
        print(c)
    }
}

To this:

if(1 in {1,2,3}):
    print(5)
    for x in c:
        print(c)

it works for messy code too. see how this can work on this long oneline code:

import time;while(1){while(3){break}if(999>x){time.sleep(1);if(2){print("This is a BAD idea.");print("Or a good one?");print("For me, this is just for fun.");print("C-Style Coding");if(1){def xyz(a,b,c){"""this is a stupid function""";print("if(2){print(\\"hi\\")}");if(a>b){return c}elif(a>c){return b}else{return a}}}with(open("file") as f){pass}}}if(1 in {1,2,3}){print(5);for(x in c){print(c)}}}

The result from the previous is:

import time
while(1):
    while(3):
        break
    if(999>x):
        time.sleep(1)
        if(2):
            print("This is a BAD idea.")
            print("Or a good one?")
            print("For me, this is just for fun.")
            print("C-Style Coding")
            if(1):
                def xyz(a,b,c):
                    """this is a stupid function"""
                    print("if(2){print(\"hi\")}")
                    if(a>b):
                        return c
                    elif(a>c):
                        return b
                    else:
                        return a
            with open("file") as f:
                pass
    if(1 in {1,2,3}):
        print(5)
        for x in c:
            print(c)

Project Info

Github project page: https://github.com/pooya-eghbali/cstyle Mail me at: persian.writer [at] Gmail.com

Release files for cstyle 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cstyle 0.1.0
File Size Uploaded
cstyle-0.1.0.zip 8.7 kB Details

Release files / cstyle-0.1.0.zip

Download URL cstyle-0.1.0.zip
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0531955438444b7a7ab751c203268e5b3e98e0f6b9e7abd3bf10f38941b91c54
BLAKE2b-256 checksum
How to use checksums
2385c3aaa984bbd9f32e724960ecc48648e29ea72d2425b1689a02602d02b56c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page