File: hijack.py

package info (click to toggle)
python-pyflow 1.1.20-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 996 kB
  • sloc: python: 4,154; sh: 219; ansic: 15; makefile: 5
file content (25 lines) | stat: -rw-r--r-- 226 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from __future__ import print_function

class A :
  def __init__(self) :
    self.x = 1

  def inc(self) :
    self.x += 1


a = A()
b = A()

a.inc()
b.inc()


# hijack:
b.inc = a.inc

b.inc()

print("a", a.x)
print("b", b.x)