Skip to main content

a simple, easy to understand language with easy integration capabilities.

Project description

Build Status Discord server invite PyPI version info PyPI supported Python versions


Viper is a simple, easy to understand language with easy integration capabilities.


Viper is available for python 3.6+.
Viper is now on pypi! It can be installed via
python -m pip install viper-lang

The dev version can be installed via

python -m pip install -U git+

And can be imported into your project

import viper

Python Usage

To use Viper in your application, make use of the two eval methods, viper.eval and viper.eval_file functions. These functions are asynchronous, and must be run using asyncio, whether that be through the await keyword, or something such as The asyncio docs can be found here.

import viper
import asyncio
code = 'myvar = "hi"'


import asyncio
import viper"myfile.vp"))

you can pass defaults to be injected into the namespace, as such

import asyncio
import viper"say(myvar)", injected={"myvar": "blue"}))

for more control over the creation, you can create your own viper.Runtime instance

import asyncio
import viper

runtime = viper.Runtime("<input>", injected={"myvar": "blue"}, allow_unsafe_imports=False)
code = "say(myvar)"

You can use this to disable features like unsafe modules, such as the requests module, or the files module.

import asyncio
import viper

runtime = viper.Runtime("<input>", allow_unsafe_imports=False)
code = "import files"

The above will raise a ViperModuleError.



variables are set like in python, but with a dollar sign ($) in front of the name. variables are retrieved in the same way, the name with a dollar sign ($) in front. variables can be marked as static by putting static in front of the variable name. static variables cannot be changed by anything other than intervention in python code

myvar = "red"

static mystaticvar = "blue"

mystaticvar = "hello"  <-- StaticError


functions are created either in python and passed to the namespace, or in viper. functions created in viper follow this syntax

func myfunc() {

quite similar to python, with a few key differences. you may put static ` in front of the `func keyword to mark the function as static, preventing it from being reassigned.

static func myfunc() {

arguments look like the following

func myfunc(argument1, argument2) {

an argument can be made optional by inserting a question mark (?) in front of the argument name, E.x.

func myfunc(argument1, ?optional_arg1) {

optional arguments that are not given will be passed as a none object (note that this is not the same as a python None)

functions are called the same as in python:

func myfunc() {


the viper namespace is left quite empty by default. The following are included in the default namespace: - say(*args) - equivilant to print in python. - help(obj) - prints an objects help. - dir(obj) - lists all attributes an object has.

Types are included in the namespace: - string - integer - bool - dictionary - list

there is also true / false, which are the booleans.

a full example

static globalvar = "hi"

func name(arg, ?arg1) {
    var = 1
    if (var is 1) {
        var += 1
    elif (var is not 1) {
        var = "stuff"
    else {
        var = none

func main() {
main() integration

to make things easier, the viper.exts.discord module makes it easy to pass safe objects, with limited accessibility, to viper, making it easy to pass models (indirectly) to your users, without fear of leaking your token and/or other sensitive data. Simply pass a model to its respective exts.discord counterpart, and pass that to your viper namespace

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for viper-lang, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size viper_lang-1.0.0-py3-none-any.whl (27.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size viper-lang-1.0.0.tar.gz (25.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page