Language comparison

ToitPython
Current objectthisself
Single line comments//#
Logical 'and', 'or' and 'not' operatorsand or notand or not
Shift left, right, unsigned right<< >> >>><< >> (no unsigned shift)
Integer division/ (on integer types)//
Integer sizes64(arbitrary)
Statement grouping(indent)(indent)
Define a class Foo that inherits from Barclass Foo extends Bar:class Foo(Bar):
Define constructor for class Fooconstructor x:def __init__(self, x):
Define constructor for class Foo that calls constructor of superclass Barconstructor x: super xdef __init__(self, x): super(Bar, self).__init__(x)
Constructor that assigns to fieldsconstructor .x:def __init__(self, x): self.x = x
Check object has typebar is Fooisinstance(bar, Foo)
Check object does not have typebar is not Foonot isinstance(bar, Foo)
Call a method foo with two argumentsfoo x yfoo(x, y)
Declare a member variable in a classx := null x := ? x/int := 0 x/int := ?self.x = null
Declare a local variable in a methodx := null x := ? x/int := 0 x/int := ?x = null
Define a constantX ::= 0
Define a constant in a classstatic X ::= 0
Define a top-level functionfoo x y:def foo(x, y):
Define an instance method in a classfoo x y:def foo(self, x, y):
Define a static method in a classstatic foo x y
If statementif condition:if condition:
Fixed loopend.repeat: | i |for i in range(end):
Three-part for loopfor i := 0; i < end; i++:
Iterate over collectioncollection.do: | x |for x in collection:
While loopwhile condition:while condition:
Import local from libraryimport .library
Import from libraryimport libraryimport library
Import into current namespaceimport library show *from library import *
Print/logprint "Hello"print("Hello")
Print with interpolationprint "Hello $name"print("Hello %s" %(name))
Interpolate with paddingprint "Hello $(%9s name)"print("Hello %9s", %(name))