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.6.0.tar.gz
(3.7 MB
view hashes)
Built Distributions
Close
Hashes for cyberlang-0.6.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7c509c41b18f1858ce4fa63c9d4611b0622914c70e1a824c9510d2ba9f4b3bd |
|
MD5 | ae00cadbfbc66f0e1cf692b32869a8d5 |
|
BLAKE2b-256 | 2845f58e893c2b7345a4adababca12283fdf783f7b346eb50d9b7a6dfb9a8c92 |
Close
Hashes for cyberlang-0.6.0-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d7b420d394bf4f44a88a02dc61cfd0c4f500570fb7ef35ea04a06bfff2756c7 |
|
MD5 | 4a249d58ed6531f9420f0273fe46b511 |
|
BLAKE2b-256 | 167d623f053c3f9d7475ecde23f8aa6dbd5fcefe1a74b2e48ced62234759232c |
Close
Hashes for cyberlang-0.6.0-py3-none-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ab558313d36a697d7fffec655195fa978e9a9a95c32685900ff96894ca18802 |
|
MD5 | 3937a154e71201829847627df90ae974 |
|
BLAKE2b-256 | 662c968fb28115207f73a92f4bd2ce369e06ebf48d4677d771ab3d0cd9b8f6b5 |
Close
Hashes for cyberlang-0.6.0-py3-none-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c78f3ef85bf4c19e68b4f8867795bd373a9a04d7aa35f1d3fa70564a3d3c77d |
|
MD5 | 1abeb02d6b9f762a722a0e5cf1b6c43b |
|
BLAKE2b-256 | 0c4b1d886cdced63101b72951337d8219944fff8181d3ebc3d795231ac59b9dd |
Close
Hashes for cyberlang-0.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2eeab38add9cc4bc265440e58b510e17312c8d9afac7121859148e8fcbd84b30 |
|
MD5 | 2bd082c58a404bf11d4ea3efb4fa870d |
|
BLAKE2b-256 | a9d15531ee8e84e7aedb2392fbb3ab6d639cb0452ad8c80db08f6b491636f825 |