Skip to main content

python with braces.

Project description

nestPython

"what if python, with braces, one line?"

SETUP

Install nestPython by executing:

$ pip install nestpython

After importing;

  • In order to compile a string from nestPython to python, use nestpython.ncompile(string)

  • In order to execute a nestPython string, use nestpython.nexec(string)

    For both, optional argument indent-level determines the indentation increment in the resulting python file. It is set to 1 by default.

  • To execute and compile files and folders, use the nestpython.files module:

    • nestpython.files.ncompile(file) compiles the given file to a string
    • nestpython.files.nexec(file) executes the file
    • nestpython.files.build(dir, new_dir) builds an entire golder
    • arguments can be provided.

Use .npy for nestPython files, .npx for nestCython files.

FEATURING:

braces

Use {, ; and } instead of indentation! Indentation and newlines in the source files will be ignored. e.g.:

n = input('Enter Number: ');
if (n % 2 == 0) {
	print('n is even')
} else {
	print('n is odd')
}

Use ~{ as a shorthand for while True {.

syntactical changes

Several keywords are altered:

Python nestPython Python nestPython
def := del ~>
return => and &&
in -> or ||
not in !> := <-
is =& assert ?!
is not !=& case ?
lambda ;= ; ,,
-> >: // ~/
+= 1 ++ -= 1 --
{ -{ } }-

A variable like return will be replaced with return_ on transpilation. pass is not required: simply use {}. Note that one-liner functions can still be written with colons: := foo(): => bar

Cython keywords are also altered for .npx:

Cython nestCython
cdef $=
cpdef ~$=

comments

  • For block comments, use /*, */.
  • For line comments, use //.
  • Block and line comments will be ignored during compilation.
  • For comments that need to be transpiled into python ones, use /|, |\ .

(to be continued)


github : https://github.com/slycedf/nestpy

pypi : https://pypi.org/project/nestpython

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

nestpython-0.3.19.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

nestpython-0.3.19-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file nestpython-0.3.19.tar.gz.

File metadata

  • Download URL: nestpython-0.3.19.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.14

File hashes

Hashes for nestpython-0.3.19.tar.gz
Algorithm Hash digest
SHA256 d3ad1508350e24756ffa7445874947c387f4c90f272f11bc40b7f4335ce6e519
MD5 343d8751a1df49c7c2a26e7377a23576
BLAKE2b-256 1954ddabbdaf4cc7820b6775897414dd5552618d1c937220533f501993a12092

See more details on using hashes here.

File details

Details for the file nestpython-0.3.19-py3-none-any.whl.

File metadata

  • Download URL: nestpython-0.3.19-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.14

File hashes

Hashes for nestpython-0.3.19-py3-none-any.whl
Algorithm Hash digest
SHA256 f453e513a82d2c7c532aa4ae6cca832090b78d439456ae8f64ee630f194114ff
MD5 863cfab00ea0fcbbf26483f4f93a2722
BLAKE2b-256 bb3b929594073899b3913fc8cd7104ffaea74a5f5806b394133f48725f11e41c

See more details on using hashes here.

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