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.1.tar.gz
(3.9 MB
view hashes)
Built Distributions
Close
Hashes for cyberlang-0.6.1-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49616d2c1925e93ad8c1a005e22c26f70454911dcda3d3fc0ed36c043af82179 |
|
MD5 | 634228db52c4d292dca7f1754d35637a |
|
BLAKE2b-256 | 607b72298eca03e9172e32acbe75fd493a5afda885c3e989c113c1366abc7a12 |
Close
Hashes for cyberlang-0.6.1-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82f6eef75082b1dac806b10561de2f939ee7f56cad2924780a72c559d2810e39 |
|
MD5 | a4bebc1334368c7e8d381a4d178c1ad2 |
|
BLAKE2b-256 | 971c1ff17bea1075f99c5e40c9ad31b96a46c3135fdaa5581387fd4f868f31a6 |
Close
Hashes for cyberlang-0.6.1-py3-none-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59f0df4ecea2d1f5d834cf4836766e73c816496eae06b02d94b85871ce472e79 |
|
MD5 | 53b997aae1c629a1550f9e28fa1e3574 |
|
BLAKE2b-256 | 0aa65ce21dcb287a6c6062727b1c9e626d3c9abb96ab05ff75bc44b4cd48a180 |
Close
Hashes for cyberlang-0.6.1-py3-none-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adbdb2a6433dba34cb1890de002f960ce23c9c03ffb80eab19e0a48044f2ae52 |
|
MD5 | 8e44b2cf09a79f658d278f8c6e906e26 |
|
BLAKE2b-256 | fded580186368b4eb9e450a5ebf49ef6241a5e412eddaf3fb6cf49693c94b518 |
Close
Hashes for cyberlang-0.6.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 524474a461c6129c70f715a796700b9f2d8fa623c97036cda575495adb07db7a |
|
MD5 | a41385069a2d2ab1a8fa7a55b0d08e4a |
|
BLAKE2b-256 | d8a266557edddc4e6bdc3ad3088e29605dfec290f8eed2f18df09530c5e65f51 |