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.5.tar.gz
(4.7 MB
view hashes)
Built Distributions
Close
Hashes for cyberlang-0.6.5-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82c763b9b697f35d19c2de0f0b114007784044dce40c82e07a3c3949abc72101 |
|
MD5 | 61b748e19f49c84831d889ddfddf1072 |
|
BLAKE2b-256 | 8e80ca22b21cf942aebf72da69b49c3a2da1d6828d083476d20c94af0453e871 |
Close
Hashes for cyberlang-0.6.5-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1461f54e107935eccc2067ed62e0929724793afcfae48568dbe9e02b0381245f |
|
MD5 | e55bafa28233ceba8614161d0cf6bfe6 |
|
BLAKE2b-256 | 96a066a5d2abdc6a0bd9ab3d171f14b242da3a0952f473cb45acb584968162f1 |
Close
Hashes for cyberlang-0.6.5-py3-none-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49a15d74a2565c74293bf4b596a866c9a97fe880d7337f9c03135bfd6e360316 |
|
MD5 | 2b2ee83d26cbd7498c185a84e70b4b0e |
|
BLAKE2b-256 | 018ceb1ecf7ad3e9a3e74fc72c52bb3ba50883060ef73485986d9094d584d47a |
Close
Hashes for cyberlang-0.6.5-py3-none-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80995eeb2227c316b24f377946289d151161d16684228770607867b0c29317d3 |
|
MD5 | 60c0e5e0a98fd334638538759820ddf4 |
|
BLAKE2b-256 | 39b3070c638867a3b9180d1b0707e0a977ead2a9690446169d192fa891ca36a5 |
Close
Hashes for cyberlang-0.6.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 910bbd276ce89e42734031bcb2dbd0148fbe7d04f5f5b59f8662675515fb3c13 |
|
MD5 | 2a5f10272129c8613839907a1755dfb6 |
|
BLAKE2b-256 | 05f06363a17a293daceabd181d52853f234429823f66ebdf42a0888a2f479f62 |