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.5.3.tar.gz
(3.7 MB
view hashes)
Built Distributions
Close
Hashes for cyberlang-0.5.3-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 678a07d46b0636a8e561d0f1867f7538aff466f2ba32899133902bdc036581b8 |
|
MD5 | 37cd5bc6a3a132f36ea61f2b7f7d6463 |
|
BLAKE2b-256 | 6536da52f8a2b6ec17c9395f9cd11a36bf65421adaee1108d9a3030f1da6f181 |
Close
Hashes for cyberlang-0.5.3-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74af7b22a1381150c6da860c782cecf167e1be58d5d89c319ea5422173823f2c |
|
MD5 | 05dbe42f500b1a0857e10db38b55c1a4 |
|
BLAKE2b-256 | 467e94ff9db39535a85395445d983a1d6ef8dbb74744c8c87bb4e3ec4808cde4 |
Close
Hashes for cyberlang-0.5.3-py3-none-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 473e75d68309a1f5413f891f14456d32444f145452a245d8aaf67f79b1506bd0 |
|
MD5 | 5dc4dad2edd1d762716fb3c272fde047 |
|
BLAKE2b-256 | a75cbb87b093a22a39ee8192fe8f2f2eade87efc8926234864e555be4a2b9764 |
Close
Hashes for cyberlang-0.5.3-py3-none-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6520c0c7eac4365bcc8f0fe08a1bb3661f5ed814ef989f6759bdb3c8a255f4d |
|
MD5 | a12a22dcfd5cd0c59ed04e502e7cdc2e |
|
BLAKE2b-256 | 9766404499e976c0490fc52782ecaecf84d494d7b7324e9941e7d2ca38697d00 |
Close
Hashes for cyberlang-0.5.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15b2a60f33833713a8975e90174a711feb23cf468ea602d175fd02ab3c240cf0 |
|
MD5 | dd703f10467d611598fecfa62e3c8ede |
|
BLAKE2b-256 | 6d10b8946ba39cf18f809d139fec8592b04e01d7d5db7f8080d7e458fbb115ef |