Python mode

x
 
1
# Literals
2
1234
3
0.0e101
4
.123
5
0b01010011100
6
0o01234567
7
0x0987654321abcdef
8
7
9
2147483647
10
3L
11
79228162514264337593543950336L
12
0x100000000L
13
79228162514264337593543950336
14
0xdeadbeef
15
3.14j
16
10.j
17
10j
18
.001j
19
1e100j
20
3.14e-10j
21
22
23
# String Literals
24
'For\''
25
"God\""
26
"""so loved
27
the world"""
28
'''that he gave
29
his only begotten\' '''
30
'that whosoever believeth \
31
in him'
32
''
33
34
# Identifiers
35
__a__
36
a.b
37
a.b.c
38
39
#Unicode identifiers on Python3
40
# a = x\ddot
41
a⃗ = 
42
# a = v\dot
43
a⃗ = 
44
45
#F\vec = m \cdot a\vec
46
F⃗ = m•a⃗ 
47
48
# Operators
49
+ - * / % & | ^ ~ < >
50
== != <= >= <> << >> // **
51
and or not in is
52
53
#infix matrix multiplication operator (PEP 465)
54
A @ B
55
56
# Delimiters
57
() [] {} , : ` = ; @ .  # Note that @ and . require the proper context on Python 2.
58
+= -= *= /= %= &= |= ^=
59
//= >>= <<= **=
60
61
# Keywords
62
as assert break class continue def del elif else except
63
finally for from global if import lambda pass raise
64
return try while with yield
65
66
# Python 2 Keywords (otherwise Identifiers)
67
exec print
68
69
# Python 3 Keywords (otherwise Identifiers)
70
nonlocal
71
72
# Types
73
bool classmethod complex dict enumerate float frozenset int list object
74
property reversed set slice staticmethod str super tuple type
75
76
# Python 2 Types (otherwise Identifiers)
77
basestring buffer file long unicode xrange
78
79
# Python 3 Types (otherwise Identifiers)
80
bytearray bytes filter map memoryview open range zip
81
82
# Some Example code
83
import os
84
from package import ParentClass
85
86
@nonsenseDecorator
87
def doesNothing():
88
    pass
89
90
class ExampleClass(ParentClass):
91
    @staticmethod
92
    def example(inputStr):
93
        a = list(inputStr)
94
        a.reverse()
95
        return ''.join(a)
96
97
    def __init__(self, mixin = 'Hello'):
98
        self.mixin = mixin
99
100

Cython mode

22
 
1
2
import numpy as np
3
cimport cython
4
from libc.math cimport sqrt
5
6
@cython.boundscheck(False)
7
@cython.wraparound(False)
8
def pairwise_cython(double[:, ::1] X):
9
    cdef int M = X.shape[0]
10
    cdef int N = X.shape[1]
11
    cdef double tmp, d
12
    cdef double[:, ::1] D = np.empty((M, M), dtype=np.float64)
13
    for i in range(M):
14
        for j in range(M):
15
            d = 0.0
16
            for k in range(N):
17
                tmp = X[i, k] - X[j, k]
18
                d += tmp * tmp
19
            D[i, j] = sqrt(d)
20
    return np.asarray(D)
21
22

Configuration Options for Python mode:

Advanced Configuration Options:

Usefull for superset of python syntax like Enthought enaml, IPython magics and questionmark help

MIME types defined: text/x-python and text/x-cython.