asjs
Python module for implement object with syntax from JavaScript. Implementing access to keys by obj.path.to.your.key notation as in JavaScript
Installing
pip install asjs
or like this:
curl https://github.com/tankalxat34/pyasjs/raw/main/asjs.py -o asjs.py
Using
Recommended import statement:
from asjs import ObjectNotation
Creating new object
Using dictionary:
obj = ObjectNotation({"key1": "value1", "key2": "value2", "key3": {"a": "b", "lst": [14, 5, 6, 12]}})
Using arguments:
obj = ObjectNotation(key1="value1", key2="value2", key3={"a": "b", "lst": [14, 5, 6, 12]})
Getting values by keys or indexes
>>> obj[0]
value1
>>> obj.key2
value2
>>> obj["key3"]
[14, 5, 6, 12]
Creating new keys in object
obj.year = 2023
or:
>>> obj.set("year", 2023)
or:
>>> year = 2023
>>> obj.set(year)
or:
>>> obj["year"] = 2023
Saving functions in object
>>> obj.fibonachi = lambda n: 1 if n <= 2 else obj.fibonachi(n - 1) + obj.fibonachi(n - 2)
>>> obj.fibonachi(7)
13
Removing keys by string-names or indexes
>>> del obj.year
or:
>>> del obj[-1]
or:
>>> del obj["year"]
Changing value by key
>>> obj.key1 = 123
or:
>>> obj["key1"] = 123
Cycle for by object
Indexes:
>>> for i in range(len(obj)):
... print(i)
0
1
2
Keys:
>>> for k in obj:
... print(k)
key1
key2
key3
fibonachi
Values:
>>> for v in obj.values():
... print(v)
123
value2
JSObject(a: 'b', lst: JSObject(0: 14, 1: 5, 2: 6, 3: 12))
<function <lambda> at 0x0000020189F19480>
Boolean statements
>>> "key3" in obj
True
>>> "fake_key" in obj
False
Metadata
Release files for asjs 0.1.3
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 |
|---|---|---|---|---|
| asjs-0.1.3.tar.gz | 5.0 kB | Without provenance | Details for asjs-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asjs-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for asjs-0.1.3-py3-none-any.whl |
Total release size: 10.0 kB
Release files / asjs-0.1.3.tar.gz
| Download URL | asjs-0.1.3.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ace5c9dd0cc3d9df76d4091c4c75a9ba6259c047efcdb783c62867e96ab2df0d
|
|
BLAKE2b-256 checksum How to use checksums |
6a0405fc151b6a685091a94c8e53e878b8f04280c7bcac7f83ef53cc2b8d94e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.1 Windows/10
|
Release files / asjs-0.1.3-py3-none-any.whl
| Download URL | asjs-0.1.3-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6fe13d379ca424d000deaed258117d8d17324cf716cb71f6e0d4006d4d7fe7f1
|
|
BLAKE2b-256 checksum How to use checksums |
a8d69fb6954693bd773e706fe49d5ab91a83e2534522ac247207228b60c58fce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.1 Windows/10
|
Security for asjs 0.1.3
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.