| 1 | # ----------------- |
| 2 | # normal |
| 3 | # ----------------- |
| 4 | a = "" |
| 5 | a = 1 |
| 6 | |
| 7 | #? int() |
| 8 | a |
| 9 | #? [] |
| 10 | a.append |
| 11 | |
| 12 | a = list |
| 13 | |
| 14 | b = 1; b = "" |
| 15 | #? str() |
| 16 | b |
| 17 | |
| 18 | # temp should not be accessible before definition |
| 19 | #? [] |
| 20 | temp |
| 21 | |
| 22 | a = 1 |
| 23 | temp = b; |
| 24 | b = a |
| 25 | a = temp |
| 26 | #? int() |
| 27 | b |
| 28 | #? int() |
| 29 | b |
| 30 | #? str() |
| 31 | a |
| 32 | |
| 33 | a = tuple |
| 34 | if 1: |
| 35 | a = list |
| 36 | |
| 37 | #? ['append'] |
| 38 | a.append |
| 39 | #? ['index'] |
| 40 | a.index |
| 41 | |
| 42 | # ----------------- |
| 43 | # tuples exchanges |
| 44 | # ----------------- |
| 45 | a, b = 1, "" |
| 46 | #? int() |
| 47 | a |
| 48 | #? str() |
| 49 | b |
| 50 | |
| 51 | b, a = a, b |
| 52 | #? int() |
| 53 | b |
| 54 | #? str() |
| 55 | a |
| 56 | |
| 57 | b, a = a, b |
| 58 | #? int() |
| 59 | a |
| 60 | #? str() |
| 61 | b |
| 62 | |
| 63 | # ----------------- |
| 64 | # function |
| 65 | # ----------------- |
| 66 | def a(a=3): |
| 67 | #? int() |
| 68 | a |
| 69 | #? [] |
| 70 | a.func |
| 71 | return a |
| 72 | |
| 73 | #? int() |
| 74 | a(2) |
| 75 | #? [] |
| 76 | a(2).func |
| 77 | |
| 78 | a_param = 3 |
| 79 | def func(a_param): |
| 80 | # should not be int |
| 81 | #? [] |
| 82 | a_param. |
| 83 | |
| 84 | from os import path |
| 85 | |
| 86 | |
| 87 | # should not return a function, because `a` is a function above |
| 88 | def f(b, a): return a |
| 89 | #? [] |
| 90 | f(b=3). |
| 91 | |
| 92 | # ----------------- |
| 93 | # closure |
| 94 | # ----------------- |
| 95 | |
| 96 | def x(): |
| 97 | a = 0 |
| 98 | |
| 99 | def x(): |
| 100 | return a |
| 101 | |
| 102 | a = 3.0 |
| 103 | return x() |
| 104 | |
| 105 | #? float() |
| 106 | x() |
| 107 | |
| 108 | # ----------------- |
| 109 | # class |
| 110 | # ----------------- |
| 111 | class A(object): |
| 112 | a = "" |
| 113 | a = 3 |
| 114 | #? int() |
| 115 | a |
| 116 | a = list() |
| 117 | def __init__(self): |
| 118 | self.b = "" |
| 119 | |
| 120 | def before(self): |
| 121 | self.b = 3 |
| 122 | # TODO should this be so? include entries after cursor? |
| 123 | #? int() str() list |
| 124 | self.b |
| 125 | self.b = list |
| 126 | |
| 127 | self.a = 1 |
| 128 | #? str() int() |
| 129 | self.a |
| 130 | |
| 131 | #? ['after'] |
| 132 | self.after |
| 133 | |
| 134 | self.c = 3 |
| 135 | #? int() |
| 136 | self.c |
| 137 | |
| 138 | def after(self): |
| 139 | self.a = '' |
| 140 | |
| 141 | c = set() |
| 142 | |
| 143 | #? list() |
| 144 | A.a |
| 145 | |
| 146 | a = A() |
| 147 | #? ['after'] |
| 148 | a.after |
| 149 | #? [] |
| 150 | a.upper |
| 151 | #? [] |
| 152 | a.append |
| 153 | #? [] |
| 154 | a.real |
| 155 | |
| 156 | #? str() int() |
| 157 | a.a |
| 158 | |
| 159 | a = 3 |
| 160 | class a(): |
| 161 | def __init__(self, a): |
| 162 | self.a = a |
| 163 | |
| 164 | #? float() |
| 165 | a(1.0).a |
| 166 | #? |
| 167 | a().a |
| 168 | |
| 169 | # ----------------- |
| 170 | # imports |
| 171 | # ----------------- |
| 172 | |
| 173 | math = 3 |
| 174 | import math |
| 175 | #? ['cosh'] |
| 176 | math.cosh |
| 177 | #? [] |
| 178 | math.real |
| 179 | |
| 180 | math = 3 |
| 181 | #? int() |
| 182 | math |
| 183 | #? [] |
| 184 | math.cos |
| 185 | |
| 186 | # do the same for star imports |
| 187 | cosh = 3 |
| 188 | from math import * |
| 189 | # cosh doesn't work, but that's not a problem, star imports should be at the |
| 190 | # start of EVERY script! |
| 191 | cosh.real |
| 192 | |
| 193 | cosh = 3 |
| 194 | #? int() |
| 195 | cosh |