1
0

index.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>CodeMirror 2: Python mode</title>
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="python.js"></script>
  8. <link rel="stylesheet" href="../../theme/default.css">
  9. <link rel="stylesheet" href="../../css/docs.css">
  10. <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
  11. </head>
  12. <body>
  13. <h1>CodeMirror 2: Python mode</h1>
  14. <div><textarea id="code" name="code">
  15. # Literals
  16. 1234
  17. 0.0e101
  18. .123
  19. 0b01010011100
  20. 0o01234567
  21. 0x0987654321abcdef
  22. 7
  23. 2147483647
  24. 3L
  25. 79228162514264337593543950336L
  26. 0x100000000L
  27. 79228162514264337593543950336
  28. 0xdeadbeef
  29. 3.14j
  30. 10.j
  31. 10j
  32. .001j
  33. 1e100j
  34. 3.14e-10j
  35. # String Literals
  36. 'For\''
  37. "God\""
  38. """so loved
  39. the world"""
  40. '''that he gave
  41. his only begotten\' '''
  42. 'that whosoever believeth \
  43. in him'
  44. ''
  45. # Identifiers
  46. __a__
  47. a.b
  48. a.b.c
  49. # Operators
  50. + - * / % & | ^ ~ < >
  51. == != <= >= <> << >> // **
  52. and or not in is
  53. # Delimiters
  54. () [] {} , : ` = ; @ . # Note that @ and . require the proper context.
  55. += -= *= /= %= &= |= ^=
  56. //= >>= <<= **=
  57. # Keywords
  58. as assert break class continue def del elif else except
  59. finally for from global if import lambda pass raise
  60. return try while with yield
  61. # Python 2 Keywords (otherwise Identifiers)
  62. exec print
  63. # Python 3 Keywords (otherwise Identifiers)
  64. nonlocal
  65. # Types
  66. bool classmethod complex dict enumerate float frozenset int list object
  67. property reversed set slice staticmethod str super tuple type
  68. # Python 2 Types (otherwise Identifiers)
  69. basestring buffer file long unicode xrange
  70. # Python 3 Types (otherwise Identifiers)
  71. bytearray bytes filter map memoryview open range zip
  72. # Some Example code
  73. import os
  74. from package import ParentClass
  75. @nonsenseDecorator
  76. def doesNothing():
  77. pass
  78. class ExampleClass(ParentClass):
  79. @staticmethod
  80. def example(inputStr):
  81. a = list(inputStr)
  82. a.reverse()
  83. return ''.join(a)
  84. def __init__(self, mixin = 'Hello'):
  85. self.mixin = mixin
  86. </textarea></div>
  87. <script>
  88. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  89. mode: {name: "python",
  90. version: 2,
  91. singleLineStringErrors: false},
  92. lineNumbers: true,
  93. indentUnit: 4,
  94. tabMode: "shift",
  95. matchBrackets: true
  96. });
  97. </script>
  98. <h2>Configuration Options:</h2>
  99. <ul>
  100. <li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
  101. <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>
  102. </ul>
  103. <p><strong>MIME types defined:</strong> <code>text/x-python</code>.</p>
  104. </body>
  105. </html>