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 => yield :>
in -> and &&
not in !> or ||
is =& := <-
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 ~$=

Strings or ternaries do not have to be one-line, but if they are not, you can use \ and # like the following.

'string \
continues here'

is equivalent to

'string continues here'

and compiles to a python string with newl This is useful to make it clear that there is a space before the newline character. The backspace is simply ignored by the compiler.

Same thing can be done with code and the # character:

a if b #
else c

is equivalent to

a if b else c

The # is ignored by the compiler.

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.24.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

nestpython-0.3.24-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nestpython-0.3.24.tar.gz
  • Upload date:
  • Size: 8.9 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.24.tar.gz
Algorithm Hash digest
SHA256 162c4715bb49c5b0a8131147951b8d6c2bc5e1a5f78d6910ac71c5fd22293bab
MD5 2cb81fa2bad9e2cb8b962cf2e52936a4
BLAKE2b-256 768dc9cea28186156251ded6cc4552d504fec3ee54d6c57a30a529db3f07a4db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nestpython-0.3.24-py3-none-any.whl
  • Upload date:
  • Size: 7.7 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.24-py3-none-any.whl
Algorithm Hash digest
SHA256 648e1f2b51a5db9c57bd23389a135e087f1f520dc33974725d9c6a672dcc4c10
MD5 9c57350b32a594cb955c7260079d5a7d
BLAKE2b-256 9983db01443e3b3195e36f0a12fb9588f9536bb44cf260ef1fbefeff099cb7fb

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