A self-contained Cyber intepreter
Project description
cyberlang - batteries included python bindings for cyber
Built with cyberlang 0.3
Installation
pip install cyberlang
Usage
Simply create a CyberVM instance and evaluate a string:
from cyber import CyberVM
vm = CyberVM()
vm.eval("print 'hello world!'")
Want to capture printed output? Override the print function from Cyber's core module with a binding.
The decorator generates all the required wrappers and interfaces, and registers everything with Cyber's VM.
from cyber import CyberVM
vm = CyberVM()
@vm.function('core.print')
def _print(string: str):
print(string)
vm.eval("print 'hello world!'")
Alternate techniques for creating callback functions:
# if no module, assume core
# same result as previous example
# this creates function "print2" in the "core" module
@cyber.function('print2')
def _print2(string: str):
print(string)
# if no module, assume core
# if no function name, use existing function name
# this creates function "test" in the "core" module
@cyber.function
def test():
print('core.test')
Or define multiple functions at once using this class-based syntax
# "core" already exists, so add a() and b() to it
class Core(cyber.module('core')):
def a(self):
print('core.test')
def b(self):
print('core.test2')
# create "new_module" and add c() and d() to it
@cyber.module('new_module')
class Module:
def c(self):
print('new_module.test')
def d(self):
print('new_module.test2')
# create module, implicitly named "NewModule" and add e() and f() to it
@cyber.module
class NewModule:
def e(self):
print('NewModule.test')
def f(self):
print('NewModule.test2')
Supporters
fubar - creator of the Cyber language
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cyberlang-0.7.1-py3-none-macosx_10_9_x86_64.whl.
File metadata
- Download URL: cyberlang-0.7.1-py3-none-macosx_10_9_x86_64.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d60e22bc3cd5abae362f6ce6521eed2384963d7f4a1fa55528439918f9f770e3
|
|
| MD5 |
97ad28adc51d6460033f5ae786708446
|
|
| BLAKE2b-256 |
ee3c138de2f187ce4f1b37323d0c2c5a876c3c1e85244c8bf94c3406b2a6b16e
|
File details
Details for the file cyberlang-0.7.1-py3-none-any.whl.
File metadata
- Download URL: cyberlang-0.7.1-py3-none-any.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1da760642b33cd7579984138007ea3b271902590fb68d394549c620358c7d83
|
|
| MD5 |
72ea2071ba95a8fffdaccdf8810b63ca
|
|
| BLAKE2b-256 |
ee2dc07254918fcd7ff1894aa411523b720a9872541cbafa47dbe789ceaf0cc0
|