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.2.tar.gz
(3.9 MB
view hashes)
Built Distributions
Close
Hashes for cyberlang-0.6.2-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d183f9e583066b207eb3ef4f75d2cbd7f443f29abcbe7eb8a17b50d32070cc5a |
|
MD5 | 346f5c0a8f105e54b6b885fcbfb23d4f |
|
BLAKE2b-256 | fded763bca34f445925331532190c991441396f226142e332555a22609f8f645 |
Close
Hashes for cyberlang-0.6.2-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a4abaedef6410c3c978e6419b12ac8f3eb7a6a739c7e5e28aae46c4afac5c8a |
|
MD5 | 228ba069d19001a73a593c10346ac245 |
|
BLAKE2b-256 | adb03e5db79cff2b67a57bc8636eaed158776d04615b84a15b407db9c29cdd8a |
Close
Hashes for cyberlang-0.6.2-py3-none-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb76db8f71c3e4da2b3544380e457bc54e441c1e65507405a746b25621e61e37 |
|
MD5 | 7d8543a0de486f60a0563e87b4cbfe99 |
|
BLAKE2b-256 | 25428eacde71e24eba7f5d54471c7bf2b011b86cfe69f29866104ab4834d0e71 |
Close
Hashes for cyberlang-0.6.2-py3-none-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5b1d4d5885236af66b9ec20a9005f9721fe4479812ff7fa77d7c7725224f9f6 |
|
MD5 | aa480bbbaa16f1a62fd7cb35e65efb57 |
|
BLAKE2b-256 | 52a3ff29451ff4f73ba51dc1353c4ea888cdc4d260197189ec1cca80bdfaa657 |
Close
Hashes for cyberlang-0.6.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e0f17d1ef404294b14ff736331e802072ab4b1327de58c4b15ef0e3128c26bb |
|
MD5 | 1b07150e9ceacf42542d54acd917a213 |
|
BLAKE2b-256 | db4b84a571bf241b39e832468ab94faeb96ac14c3f380e1ba8ba9442ed89cfdb |