A self-contained Cyber intepreter
Project description
cyberlang - batteries included python bindings for cyber
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 Distribution
cyberlang-0.7.0.tar.gz
(4.4 MB
view hashes)
Built Distributions
Close
Hashes for cyberlang-0.7.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d763ca3acd57a4ecc90400bc763bfa0adb969299a59e058eff569de880edfc5 |
|
MD5 | 755eea3781abd166b709f12d3b37f99b |
|
BLAKE2b-256 | 115d9aad936686f00e2771c79a5dca5a4d25f1cb3a424d521b9ed3ab95f9879c |
Close
Hashes for cyberlang-0.7.0-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e250054844e50e5a23b80282bbf7da8055d500169530b8d90b14456944ffb448 |
|
MD5 | 9a0f912f71f0ab42efebbb627cf4d6b8 |
|
BLAKE2b-256 | 4d9ca646a23b2a5f9bf0776416ae43ab6dc49b3cf6cd21538f676b4a45a1a410 |
Close
Hashes for cyberlang-0.7.0-py3-none-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e10556d17bc0aec79801d4ba1ac2b01b2fde753702275068ec0019268f4784ec |
|
MD5 | d454412abaf760d4ecf88d0e75a4ab95 |
|
BLAKE2b-256 | a87c116642ebc9f45f1f0bc0e4ce43c3edcba45e3c474757da7e95d875d162db |
Close
Hashes for cyberlang-0.7.0-py3-none-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaa2643066090f2476876117bed0fed83771dcdeff04d19b0f72040dc67463d6 |
|
MD5 | 62c88c3d9f7b77abf2937607fa3c96eb |
|
BLAKE2b-256 | 89e57ea5a497562f02f52b815125c2e64e58f05d0331d7ef0e252e42ff48fbf5 |
Close
Hashes for cyberlang-0.7.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eeed27dd13b19a14848558cda4b7b1a3e1e29e80fb62e879837bb291e6c70888 |
|
MD5 | 3f2e1ad9ba4528614f24af1cc9c58a26 |
|
BLAKE2b-256 | d326099dd78244758d45a4b4a9e5810c924e06ff5a0361b3c7fb8abcb3594548 |