Giter Club home page Giter Club logo

likepy's Introduction

Likepy

Likepy is a library that helps to exec or eval the following python-like languages within a trusted environment:

  • RestrictedPython
  • starlark (progressing)

⚠️ Likepy only supports CPython. It does not support PyPy and other Python implementations.

starlark's differences with python

Global variables are immutable.

for statements are not allowed at the top-level. Use them within functions instead. In BUILD files, you may use list comprehensions.

if statements are not allowed at the top-level. However, if expressions can be used: first = data[0] if len(data) > 0 else None.

Deterministic order for iterating through Dictionaries.

Recursion is not allowed.

Int type is limited to 32-bit signed integers. Overflows will throw an error.

Modifying a collection during iteration is an error.

Except for equality tests, comparison operators <, <=, >=, >, etc. are not defined across value types. In short: 5 < 'foo' will throw an error and 5 == "5" will return false.

In tuples, a trailing comma is valid only when the tuple is between parentheses, e.g. write (1,) instead of 1,.

Dictionary literals cannot have duplicated keys. For example, this is an error: {"a": 4, "b": 7, "a": 1}.

Strings are represented with double-quotes (e.g. when you call repr).

Strings aren’t iterable.

The following Python features are not supported:

implicit string concatenation (use explicit + operator).

Chained comparisons (e.g. 1 < x < 5).

class (see struct function).

import (see load statement).

while, yield.

float and set types.

generators and generator expressions.

lambda and nested functions.

is (use == instead).

try, raise, except, finally (see fail for fatal errors).

global, nonlocal.

most builtin functions, most methods.

likepy's People

Contributors

zeaphoo avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.