FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
testing/sqlphp/developer-notes/python/python2.txt at main · astechedu/testing · GitHub
astechedu
/
testing
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
testing
/
sqlphp
/
developer-notes
/
python
/
python2.txt
Copy path
More file actions
More file actions
Latest commit
History
History
History
124 lines (70 loc) · 1.64 KB
Breadcrumbs
testing
/
sqlphp
/
developer-notes
/
python
/
python2.txt
Copy path
File metadata and controls
124 lines (70 loc) · 1.64 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<<<<< Python <<<<<<
-------------------------------------------------------------------
-------------------------------------------------------------------------------------
Function Description
__init__() initialize the attributes of the object
__str__() returns a string representation of the object
__len__() returns the length of the object
__add__() adds two objects
__call__() call objects of the class like a normal function
--------------------------------------------------------------------------------------
Python Overloading:
class Point:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def __str__(self):
return "({0},{1})".format(self.x, self.y)
def __add__(self, other):
x = self.x + other.x
y = self.y + other.y
return Point(x, y)
p1 = Point(1, 2)
p2 = Point(2, 3)
print(p1+p2)
# Output: (3,5)
------------------------------------------------------------------
//https://www.programiz.com/python-programming/operator-overloading
Operator
Expression
Internally
Addition
p1 + p2
p1.__add__(p2)
Subtraction
p1 - p2
p1.__sub__(p2)
Multiplication
p1 * p2
p1.__mul__(p2)
Power
p1 ** p2
p1.__pow__(p2)
Division
p1 / p2
p1.__truediv__(p2)
Floor Division
p1 // p2
p1.__floordiv__(p2)
Remainder (modulo)
p1 % p2
p1.__mod__(p2)
Bitwise Left Shift
p1 << p2
p1.__lshift__(p2)
Bitwise Right Shift
p1 >> p2
p1.__rshift__(p2)
Bitwise AND
p1 & p2
p1.__and__(p2)
Bitwise OR
p1 | p2
p1.__or__(p2)
Bitwise XOR
p1 ^ p2
p1.__xor__(p2)
Bitwise NOT
~p1
p1.__invert__()
--------------------------------------------------
Back
|
FazBrowse Home
|
New Git URL