Python mode

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
# Operators
40
+ - * / % & | ^ ~ < >
41
== != <= >= <> << >> // **
42
and or not in is
43
 
44
# Delimiters
45
() [] {} , : ` = ; @ .  # Note that @ and . require the proper context.
46
+= -= *= /= %= &= |= ^=
47
//= >>= <<= **=
48
 
49
# Keywords
50
as assert break class continue def del elif else except
51
finally for from global if import lambda pass raise
52
return try while with yield
53
 
54
# Python 2 Keywords (otherwise Identifiers)
55
exec print
56
 
57
# Python 3 Keywords (otherwise Identifiers)
58
nonlocal
59
 
60
# Types
61
bool classmethod complex dict enumerate float frozenset int list object
62
property reversed set slice staticmethod str super tuple type
63
 
64
# Python 2 Types (otherwise Identifiers)
65
basestring buffer file long unicode xrange
66
 
67
# Python 3 Types (otherwise Identifiers)
68
bytearray bytes filter map memoryview open range zip
69
 
70
# Some Example code
71
import os
72
from package import ParentClass
73
 
74
@nonsenseDecorator
75
def doesNothing():
76
    pass
77
 
78
class ExampleClass(ParentClass):
79
    @staticmethod
80
    def example(inputStr):
81
        a = list(inputStr)
82
        a.reverse()
83
        return ''.join(a)
84
 
85
    def __init__(self, mixin = 'Hello'):
86
        self.mixin = mixin
87
 
88
 
 

Cython mode

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.