jexp
- synopsis:
A silly little JS expression builder to let you use native Python to build Javascript expression strings.
This package only allows the creation of simple (that is, non-assignment) Javascript expressions using an intuitive Python DSL.
Logical Expressions
>>> from jexp import J>>> e = J('var_1') & J('var_2')>>> str(e)‘(var_1&&var_2)’
>>> str(e | 'abc')‘((var_1&&var_2)||”abc”)’
The argument to the J class will be output as a str in the resulting JS- so J('my_var') is a good way to refer to a var, and J(5) to the number literal 5. If you need an actual string, you can either add the quotes yourself in the J call - J('"my string"') - or otherwise combine the J object with a str, as shown above.
Mathematical Expressions
>>> str(J(5) + 28)‘(5+28)’
>>> str(J('my_var') + 28)‘(my_var+28)’
Division hasn’t been implemented, but other things you expect are there.
Comparisons
>>> e = J(5) <= 6>>> str(e)‘(5<=6)’
>>> str(e == "test_string")‘((5<=6)==”test_string”)’
Attribute Access
>>> e = J('my_var').attribute>>> str(e)‘my_var.attribute’
This should work for any attribute that doesn’t start with an underscore (and some that do).
Function Calling
>>> e = J('func')('a','b')>>> str(e)‘func(“a”,”b”)’
You can also try this with other J objects.
>>> str(J('func')(J('arg1'),J('arg2')))‘func(arg1,arg2)’
Metadata
Release files for jexp 0.1.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 |
|---|---|---|---|---|
| jexp-0.1.2.tar.gz | 3.8 kB | Without provenance | Details for jexp-0.1.2.tar.gz |
Release files / jexp-0.1.2.tar.gz
| Download URL | jexp-0.1.2.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
980daba6f53013f2af27800e88954b81e841ecda3c85fb9f4fcdc5e2c227f19f
|
|
BLAKE2b-256 checksum How to use checksums |
37b5f424ca5f1f0dffc6a2ccc1a03fb72a308e877af9f886370234a8cebe46d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for jexp 0.1.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.