Syntax/type support

The goal is to support a useful subset of Python syntax and keep the resulting files small.

Python reference details more about specific types and global functions.

What is supported

Types

  • int
  • string (unicode only)
  • list
  • dict
  • bool (note)
  • None
  • tuple (note: treated as list and mutable)
  • functions (you can nest them, assign to variables, pass then around, invoke, closures, apply())

Keywords

  • def (new methods)
  • if
  • while
  • for (iterate over list members and dict keys)
  • return
  • del
  • lambda

Operators

  • boolean: and, or
  • + - * / // % (Where applicable for types. Division is always floor division.)
  • < <= == != >= > (note)
  • in / not in (list/dict membership)
  • is / is not (same object checking)
  • len (as applicable)
  • [] (list and dict indexing)
  • [from:to] list slicing (step not supported)
  • x if y else z (ternary)
  • Augmented assignments += -= /= etc (note)
  • List comprehensions

What is not supported

  • docstrings are seen but ignored. You cannot retrieve them. They do not end up in the output jmp file.

  • Variable arguments and keyword arguments (*args and **kwargs). Note that methods added in Java/ObjC can take variable numbers of arguments. You can call apply() to call a function with a list of arguments.

  • Default arguments

  • Bitwise operators (<< >> & | ^)

  • Classes - note however that there is a useful approximation

  • Decorators

  • Threads (mutexes ensure only one call at a time into Jia Mini Python can happen)

  • Exceptions

  • More than one source file/module

  • Generators

  • Import

  • With

  • Tuple unpacking. For example:

    for x,y in z:
        pass
    
  • Floating point

  • Bytes type

  • Assignment to False/True/None (allowed in some Python versions to change value).

Exceptions

Exceptions are not supported nor is try/except. If you do something that results in an exception (eg adding a number to a string) then a Java level exception will be thrown, or Objective C error returned.

If you do need to be highly dynamic then consider using the Look Before You Leap style where you make checks before performing operations that can fail. Note that multi-threading is not supported (serialised) so there are no race conditions.

Table Of Contents

Previous topic

Example

Next topic

Java API Reference

This Page