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.3.tar.gz
(4.8 MB
view hashes)
Built Distributions
Close
Hashes for cyberlang-0.6.3-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab3f35031ea6210f713da35e5fbfc838f33368ccda5e52529d7c0c57634f0891 |
|
MD5 | 07a148a9e4be1473310ddea36b7e4f4a |
|
BLAKE2b-256 | a9b43232dcfcc10873165e1ec817137c0fee9113c2e35c829552283e91ed6f23 |
Close
Hashes for cyberlang-0.6.3-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb3f3c80869c7c011e156542de99b32f4744ab026181b2616d4cfb23db63422a |
|
MD5 | d7403e0035a6634913b1727253e11eda |
|
BLAKE2b-256 | e1f3f798c613b7d92d5e6062f32f969360206b7394431364857dfce60fb7aa9f |
Close
Hashes for cyberlang-0.6.3-py3-none-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 100b4a06513a9f2b31d68d068427691fd431df8381aab2baff735eeac7f6d2e7 |
|
MD5 | e8d35cf6debd8573b277a3154021244b |
|
BLAKE2b-256 | c95bb7e9c5625b94129ac0ca0f2318d97e7b36a988102827e8bede2479ee2606 |
Close
Hashes for cyberlang-0.6.3-py3-none-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26781c612a2d2cccf2e85bb6e21fa78f6fd771ff7aecaab0d43d0845e0dbf33a |
|
MD5 | 7e8e928a0cef53ec0c4dae9ba21a43fb |
|
BLAKE2b-256 | 6d0f87282111c9598f95d01e4b3406b28d695f1f53af130b78ef8fdb6e4fc66c |
Close
Hashes for cyberlang-0.6.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 225d3cccc76d0a428599646b6e9e4d0d3e30abd1d7fc4911a8c8186d6f7d8ecd |
|
MD5 | 8b557b3ae52aed75e44c464e5febd2f6 |
|
BLAKE2b-256 | c077f5a25375d310617c6d5edceda7ee8dff592963bec1e6bcb3af5687aafb1f |