5 <title>CodeMirror: Python mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="python.js"></script>
10 <link rel="stylesheet" href="../../doc/docs.css">
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
14 <h1>CodeMirror: Python mode</h1>
16 <div><textarea id="code" name="code">
27 79228162514264337593543950336L
29 79228162514264337593543950336
45 his only begotten\' '''
46 'that whosoever believeth \
57 == != <= >= <> << >> // **
61 () [] {} , : ` = ; @ . # Note that @ and . require the proper context.
62 += -= *= /= %= &= |= ^=
66 as assert break class continue def del elif else except
67 finally for from global if import lambda pass raise
68 return try while with yield
70 # Python 2 Keywords (otherwise Identifiers)
73 # Python 3 Keywords (otherwise Identifiers)
77 bool classmethod complex dict enumerate float frozenset int list object
78 property reversed set slice staticmethod str super tuple type
80 # Python 2 Types (otherwise Identifiers)
81 basestring buffer file long unicode xrange
83 # Python 3 Types (otherwise Identifiers)
84 bytearray bytes filter map memoryview open range zip
88 from package import ParentClass
94 class ExampleClass(ParentClass):
96 def example(inputStr):
101 def __init__(self, mixin = 'Hello'):
109 <div><textarea id="code-cython" name="code-cython">
113 from libc.math cimport sqrt
115 @cython.boundscheck(False)
116 @cython.wraparound(False)
117 def pairwise_cython(double[:, ::1] X):
118 cdef int M = X.shape[0]
119 cdef int N = X.shape[1]
121 cdef double[:, ::1] D = np.empty((M, M), dtype=np.float64)
126 tmp = X[i, k] - X[j, k]
134 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
135 mode: {name: "python",
137 singleLineStringErrors: false},
144 CodeMirror.fromTextArea(document.getElementById("code-cython"), {
145 mode: {name: "text/x-cython",
147 singleLineStringErrors: false},
154 <h2>Configuration Options for Python mode:</h2>
156 <li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
157 <li>singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</li>
159 <h2>Advanced Configuration Options:</h2>
160 <p>Usefull for superset of python syntax like Enthought enaml, IPython magics and questionmark help</p>
162 <li>singleOperators - RegEx - Regular Expression for single operator matching, default : <pre>^[\\+\\-\\*/%&|\\^~<>!]</pre></li>
163 <li>singleDelimiters - RegEx - Regular Expression for single delimiter matching, default : <pre>^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]</pre></li>
164 <li>doubleOperators - RegEx - Regular Expression for double operators matching, default : <pre>^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))</pre></li>
165 <li>doubleDelimiters - RegEx - Regular Expressoin for double delimiters matching, default : <pre>^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))</pre></li>
166 <li>tripleDelimiters - RegEx - Regular Expression for triple delimiters matching, default : <pre>^((//=)|(>>=)|(<<=)|(\\*\\*=))</pre></li>
167 <li>identifiers - RegEx - Regular Expression for identifier, default : <pre>^[_A-Za-z][_A-Za-z0-9]*</pre></li>
168 <li>extra_keywords - list of string - List of extra words ton consider as keywords</li>
169 <li>extra_builtins - list of string - List of extra words ton consider as builtins</li>
173 <p><strong>MIME types defined:</strong> <code>text/x-python</code> and <code>text/x-cython</code>.</p>