| 1 |
def find_class(): |
| 2 |
""" This scope is special, because its in front of TestClass """ |
| 3 |
|
| 4 |
TestClass.ret |
| 5 |
if 1: |
| 6 |
|
| 7 |
TestClass.ret |
| 8 |
|
| 9 |
class FindClass(): |
| 10 |
|
| 11 |
TestClass.ret |
| 12 |
if a: |
| 13 |
|
| 14 |
TestClass.ret |
| 15 |
|
| 16 |
def find_class(self): |
| 17 |
|
| 18 |
TestClass.ret |
| 19 |
if 1: |
| 20 |
|
| 21 |
TestClass.ret |
| 22 |
|
| 23 |
|
| 24 |
FindClass().find_class.self |
| 25 |
|
| 26 |
FindClass().find_class.self.find_class |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
second = 1 |
| 31 |
second = "" |
| 32 |
class TestClass(object): |
| 33 |
var_class = TestClass(1) |
| 34 |
self.pseudo_var = 3 |
| 35 |
|
| 36 |
def __init__(self2, first_param, second_param, third=1.0): |
| 37 |
self2.var_inst = first_param |
| 38 |
self2.second = second_param |
| 39 |
self2.first = first_param |
| 40 |
self2.first.var_on_argument = 5 |
| 41 |
a = 3 |
| 42 |
|
| 43 |
def var_func(self): |
| 44 |
return 1 |
| 45 |
|
| 46 |
def get_first(self): |
| 47 |
|
| 48 |
self.second_new = self.second |
| 49 |
return self.var_inst |
| 50 |
|
| 51 |
def values(self): |
| 52 |
self.var_local = 3 |
| 53 |
|
| 54 |
self.var_ |
| 55 |
|
| 56 |
var_local |
| 57 |
|
| 58 |
def ret(self, a1): |
| 59 |
|
| 60 |
|
| 61 |
values |
| 62 |
|
| 63 |
values |
| 64 |
|
| 65 |
ret |
| 66 |
return a1 |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
var_local |
| 71 |
|
| 72 |
var_inst |
| 73 |
|
| 74 |
var_func |
| 75 |
|
| 76 |
|
| 77 |
inst = TestClass(1) |
| 78 |
|
| 79 |
|
| 80 |
inst.var |
| 81 |
|
| 82 |
|
| 83 |
TestClass.var |
| 84 |
|
| 85 |
|
| 86 |
inst.var_local |
| 87 |
|
| 88 |
TestClass.var_local. |
| 89 |
|
| 90 |
TestClass.pseudo_var |
| 91 |
|
| 92 |
TestClass().pseudo_var |
| 93 |
|
| 94 |
|
| 95 |
TestClass().ret(1) |
| 96 |
|
| 97 |
|
| 98 |
TestClass().ret(1) |
| 99 |
|
| 100 |
inst.ret(1) |
| 101 |
|
| 102 |
myclass = TestClass(1, '', 3.0) |
| 103 |
|
| 104 |
myclass.get_first() |
| 105 |
|
| 106 |
myclass.get_first.real |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
TestClass(1,1,1).var_inst |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
TestClass(1).first |
| 115 |
|
| 116 |
TestClass(1).second. |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
myclass.second |
| 121 |
|
| 122 |
myclass.second_new |
| 123 |
|
| 124 |
|
| 125 |
ints = TestClass(1, 1.0) |
| 126 |
strs = TestClass("", '') |
| 127 |
|
| 128 |
ints.second |
| 129 |
|
| 130 |
strs.second |
| 131 |
|
| 132 |
|
| 133 |
TestClass.var_class.var_class.var_class.var_class |
| 134 |
|
| 135 |
|
| 136 |
class A(): |
| 137 |
def __init__(self): |
| 138 |
self.addition = 1 + 2 |
| 139 |
|
| 140 |
A().addition |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
A().addition = None |
| 145 |
|
| 146 |
A(1).addition = None |
| 147 |
|
| 148 |
A(1).addition = None |
| 149 |
a = A() |
| 150 |
|
| 151 |
a.addition = None |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
class Base(object): |
| 159 |
def method_base(self): |
| 160 |
return 1 |
| 161 |
|
| 162 |
class SuperClass(Base): |
| 163 |
class_super = 3 |
| 164 |
def __init__(self): |
| 165 |
self.var_super = '' |
| 166 |
def method_super(self): |
| 167 |
self.var2_super = list |
| 168 |
|
| 169 |
class Mixin(SuperClass): |
| 170 |
def method_mixin(self): |
| 171 |
return int |
| 172 |
|
| 173 |
|
| 174 |
class SubClass(SuperClass): |
| 175 |
class_sub = 3 |
| 176 |
def __init__(self): |
| 177 |
self.var_sub = '' |
| 178 |
def method_sub(self): |
| 179 |
self.var_sub = list |
| 180 |
return tuple |
| 181 |
|
| 182 |
instance = SubClass() |
| 183 |
|
| 184 |
|
| 185 |
instance.method_ |
| 186 |
|
| 187 |
instance.var |
| 188 |
|
| 189 |
instance.class_ |
| 190 |
|
| 191 |
|
| 192 |
SubClass.method_ |
| 193 |
|
| 194 |
SubClass.var |
| 195 |
|
| 196 |
SubClass.class_ |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
class Base(str): |
| 203 |
pass |
| 204 |
|
| 205 |
|
| 206 |
Base.upper |
| 207 |
|
| 208 |
Base().upper |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
class Angry(object): |
| 215 |
def shout(self): |
| 216 |
return 'THIS IS MALARKEY!' |
| 217 |
|
| 218 |
def classgetter(): |
| 219 |
return Angry |
| 220 |
|
| 221 |
class Dude(classgetter()): |
| 222 |
def react(self): |
| 223 |
|
| 224 |
self.s |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
class FactorMixin(object): |
| 231 |
FACTOR_1 = 0.1 |
| 232 |
|
| 233 |
class Calc(object): |
| 234 |
def sum(self, a, b): |
| 235 |
self.xxx = 3 |
| 236 |
return a + b |
| 237 |
|
| 238 |
class BetterCalc(Calc, FactorMixin): |
| 239 |
def multiply_factor(self, a): |
| 240 |
return a * self.FACTOR_1 |
| 241 |
|
| 242 |
calc = BetterCalc() |
| 243 |
|
| 244 |
calc.sum |
| 245 |
|
| 246 |
calc.multip |
| 247 |
|
| 248 |
calc.FACTOR_1 |
| 249 |
|
| 250 |
calc.xxx |
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
class CallClass(): |
| 257 |
def __call__(self): |
| 258 |
return 1 |
| 259 |
|
| 260 |
|
| 261 |
CallClass()() |
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
class V: |
| 268 |
def __init__(self, a): |
| 269 |
self.a = a |
| 270 |
|
| 271 |
def ret(self): |
| 272 |
return self.a |
| 273 |
|
| 274 |
d = b |
| 275 |
b = ret |
| 276 |
if 1: |
| 277 |
c = b |
| 278 |
|
| 279 |
|
| 280 |
V(1).b() |
| 281 |
|
| 282 |
V(1).c() |
| 283 |
|
| 284 |
V(1).d() |
| 285 |
|
| 286 |
|
| 287 |
V(1).d() |
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
class A(): |
| 294 |
def b(self): |
| 295 |
|
| 296 |
a_func() |
| 297 |
|
| 298 |
self.a_func() |
| 299 |
return a_func() |
| 300 |
|
| 301 |
def a_func(self): |
| 302 |
return "" |
| 303 |
|
| 304 |
def a_func(): |
| 305 |
return 1 |
| 306 |
|
| 307 |
|
| 308 |
A().b() |
| 309 |
|
| 310 |
A().a_func() |
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
class A(): |
| 316 |
class B(): |
| 317 |
pass |
| 318 |
def b(self): |
| 319 |
return 1.0 |
| 320 |
|
| 321 |
|
| 322 |
A().b() |
| 323 |
|
| 324 |
class A(): |
| 325 |
def b(self): |
| 326 |
class B(): |
| 327 |
def b(self): |
| 328 |
return [] |
| 329 |
return B().b() |
| 330 |
|
| 331 |
|
| 332 |
A().b() |
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
def meth(self): |
| 339 |
return self.a, self.b |
| 340 |
|
| 341 |
class WithoutMethod(): |
| 342 |
a = 1 |
| 343 |
def __init__(self): |
| 344 |
self.b = 1.0 |
| 345 |
def blub(self): |
| 346 |
return self.b |
| 347 |
m = meth |
| 348 |
|
| 349 |
class B(): |
| 350 |
b = '' |
| 351 |
|
| 352 |
a = WithoutMethod().m() |
| 353 |
|
| 354 |
a[0] |
| 355 |
|
| 356 |
a[1] |
| 357 |
|
| 358 |
|
| 359 |
WithoutMethod.blub(WithoutMethod()) |
| 360 |
|
| 361 |
WithoutMethod.blub(B()) |
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
getattr(str(), 'upper') |
| 369 |
|
| 370 |
getattr(str, 'upper') |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
getattr(str, 1) |
| 375 |
|
| 376 |
getattr() |
| 377 |
|
| 378 |
getattr(str) |
| 379 |
|
| 380 |
getattr(getattr, 1) |
| 381 |
|
| 382 |
getattr(str, []) |
| 383 |
|
| 384 |
|
| 385 |
class Base(): |
| 386 |
def ret(self, b): |
| 387 |
return b |
| 388 |
|
| 389 |
class Wrapper(): |
| 390 |
def __init__(self, obj): |
| 391 |
self.obj = obj |
| 392 |
|
| 393 |
def __getattr__(self, name): |
| 394 |
return getattr(self.obj, name) |
| 395 |
|
| 396 |
class Wrapper2(): |
| 397 |
def __getattribute__(self, name): |
| 398 |
return getattr(Base(), name) |
| 399 |
|
| 400 |
|
| 401 |
Wrapper(Base()).ret(3) |
| 402 |
|
| 403 |
Wrapper(Base()).ret |
| 404 |
|
| 405 |
Wrapper(Wrapper(Base())).ret(3) |
| 406 |
|
| 407 |
Wrapper(Wrapper(Base())).ret |
| 408 |
|
| 409 |
|
| 410 |
Wrapper2(Base()).ret(3) |
| 411 |
|
| 412 |
class GetattrArray(): |
| 413 |
def __getattr__(self, name): |
| 414 |
return [1] |
| 415 |
|
| 416 |
|
| 417 |
GetattrArray().something[0] |
| 418 |
|
| 419 |
GetattrArray().something |
| 420 |
|
| 421 |
class WeirdGetattr: |
| 422 |
class __getattr__(): |
| 423 |
pass |
| 424 |
|
| 425 |
|
| 426 |
WeirdGetattr().something |
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
class PrivateVar(): |
| 433 |
def __init__(self): |
| 434 |
self.__var = 1 |
| 435 |
|
| 436 |
self.__var |
| 437 |
|
| 438 |
self.__var |
| 439 |
|
| 440 |
def __private_func(self): |
| 441 |
return 1 |
| 442 |
|
| 443 |
|
| 444 |
__private_func() |
| 445 |
|
| 446 |
def wrap_private(self): |
| 447 |
return self.__private_func() |
| 448 |
|
| 449 |
PrivateVar().__var |
| 450 |
|
| 451 |
PrivateVar().__var |
| 452 |
|
| 453 |
PrivateVar().__private_func |
| 454 |
|
| 455 |
PrivateVar.__private_func |
| 456 |
|
| 457 |
PrivateVar().wrap_private() |
| 458 |
|
| 459 |
|
| 460 |
class PrivateSub(PrivateVar): |
| 461 |
def test(self): |
| 462 |
|
| 463 |
self.__var |
| 464 |
|
| 465 |
def wrap_private(self): |
| 466 |
|
| 467 |
self.__var |
| 468 |
|
| 469 |
|
| 470 |
PrivateSub().__var |
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
class Super(object): |
| 476 |
a = 3 |
| 477 |
def return_sup(self): |
| 478 |
return 1 |
| 479 |
SuperCopy = Super |
| 480 |
|
| 481 |
class TestSuper(Super): |
| 482 |
|
| 483 |
super() |
| 484 |
def test(self): |
| 485 |
|
| 486 |
super() |
| 487 |
|
| 488 |
super().a |
| 489 |
if 1: |
| 490 |
|
| 491 |
super() |
| 492 |
def a(): |
| 493 |
|
| 494 |
super() |
| 495 |
|
| 496 |
def return_sup(self): |
| 497 |
|
| 498 |
return super().return_sup() |
| 499 |
|
| 500 |
|
| 501 |
TestSuper().return_sup() |
| 502 |
|
| 503 |
|
| 504 |
Super = 3 |
| 505 |
|
| 506 |
class Foo(): |
| 507 |
def foo(self): |
| 508 |
return 1 |
| 509 |
|
| 510 |
class Foo(Foo): |
| 511 |
def foo(self): |
| 512 |
|
| 513 |
super().foo() |
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
class TestX(object): |
| 519 |
def normal_method(self): |
| 520 |
return 1 |
| 521 |
|
| 522 |
if True: |
| 523 |
def conditional_method(self): |
| 524 |
var = self.normal_method() |
| 525 |
|
| 526 |
var |
| 527 |
return 2 |
| 528 |
|
| 529 |
def other_method(self): |
| 530 |
var = self.conditional_method() |
| 531 |
|
| 532 |
var |
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
class A(object): |
| 539 |
a = 3 |
| 540 |
|
| 541 |
|
| 542 |
A.mro |
| 543 |
|
| 544 |
A().mro |
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
class B(A()): |
| 552 |
b = 3 |
| 553 |
|
| 554 |
|
| 555 |
B.a |
| 556 |
|
| 557 |
B().a |
| 558 |
|
| 559 |
B.b |
| 560 |
|
| 561 |
B().b |
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
from import_tree.classes import Config2, BaseClass |
| 569 |
|
| 570 |
class Config(BaseClass): |
| 571 |
"""#884""" |
| 572 |
|
| 573 |
|
| 574 |
Config.mode |
| 575 |
|
| 576 |
|
| 577 |
Config.mode2 |
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
class Foo(object): |
| 584 |
a = 3 |
| 585 |
def create_class(self): |
| 586 |
class X(): |
| 587 |
a = self.a |
| 588 |
self.b = 3.0 |
| 589 |
return X |
| 590 |
|
| 591 |
|
| 592 |
Foo().create_class().a |
| 593 |
|
| 594 |
Foo().b |
| 595 |
|
| 596 |
class Foo(object): |
| 597 |
def comprehension_definition(self): |
| 598 |
return [1 for self.b in [1]] |
| 599 |
|
| 600 |
|
| 601 |
Foo().b |
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
default = '' |
| 608 |
class DefaultArg(): |
| 609 |
default = 3 |
| 610 |
def x(self, arg=default): |
| 611 |
|
| 612 |
default |
| 613 |
return arg |
| 614 |
def y(self): |
| 615 |
return default |
| 616 |
|
| 617 |
|
| 618 |
DefaultArg().x() |
| 619 |
|
| 620 |
DefaultArg().y() |
| 621 |
|
| 622 |
DefaultArg.x() |
| 623 |
|
| 624 |
DefaultArg.y() |
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
from import_tree.pkg.base import MyBase |
| 632 |
|
| 633 |
class C1(MyBase): |
| 634 |
def f3(self): |
| 635 |
|
| 636 |
self.f1() . |
| 637 |
|
| 638 |
self.f1() . |
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
class WithWeirdInit: |
| 645 |
class __init__: |
| 646 |
def __init__(self, a): |
| 647 |
self.a = a |
| 648 |
|
| 649 |
def y(self): |
| 650 |
return self.a |
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
WithWeirdInit(1).y() |