Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uyjulian/pytjs
TJS2 bindings to Python
https://github.com/uyjulian/pytjs
Last synced: 6 days ago
JSON representation
TJS2 bindings to Python
- Host: GitHub
- URL: https://github.com/uyjulian/pytjs
- Owner: uyjulian
- License: mit
- Created: 2021-02-15T03:57:52.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-01T00:13:45.000Z (over 3 years ago)
- Last Synced: 2024-10-18T20:37:53.973Z (27 days ago)
- Language: C++
- Size: 443 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pytjs
## About
This repository contains a Python interface to TJS2.
## Installation (from PyPI)
```bash
python3 -m pip install pytjs
```## Installation (from source)
First, clone this repository, including all submodules.
```bash
git clone --recursive https://github.com/uyjulian/pytjs.git
```
Now, you can run `pip install` on the repository path.
```bash
python3 -m pip install ./pytjs
```## Usage
Firstly, you need to initialize a TJS script engine.
```py
import pytjsScriptEngine = pytjs.tTJS()
```
You can then get things in its global environment.
```py
ScriptEngineGlobal = ScriptEngine.GetGlobal()
print(ScriptEngineGlobal.Dictionary) #
# or
print(ScriptEngineGlobal['Dictionary']) #
```
You can also set values in the global environment.
```py
ScriptEngineGlobal = ScriptEngine.GetGlobal()
ScriptEngineGlobal.test = "test"
# or
ScriptEngineGlobal["test"] = "test"
```
You can evaluate expressions in the script engine environment.
```py
print(ScriptEngine.EvalExpression("123")) # 123
# 123
```
You can iterate through Array and Dictionary objects.
```py
arr = ScriptEngine.EvalExpression("['test', 'test2']")
for v in arr:
print(v)
# test
# test2
dic = ScriptEngine.EvalExpression("%['test' => 'test2']")
for v in dic:
print(v, dic[v])
# test
# test2
```## License
This project is licensed under the MIT license. Please read the `LICENSE` file for more information.