Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 48e6feb

Browse files
Utility Methods
1 parent bdb88aa commit 48e6feb

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

quickmongo/Util.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,31 @@ def startswith(self, data, query: str):
1313

1414
return result
1515

16-
# To make dict to an object
17-
16+
# Convert dict to attr
1817
class AttrDict():
1918

20-
def __init__(self, paramdict: dict):
21-
for key in paramdict:
22-
setattr(self, key, paramdict[key])
19+
def __init__(self, arg: dict):
20+
for key in arg.keys():
21+
setattr(self, key, arg[key])
22+
23+
# Math Functions
24+
def add(a: int, b:int):
25+
return a + b
26+
def subtract(a: int, b:int):
27+
return a - b
28+
def multiply(a: int, b:int):
29+
return a * b
30+
def divide(a: int, b:int):
31+
return a / b
32+
def power(a: int, b:int):
33+
return a ** b
34+
35+
# Variables
36+
math_symbols = ['+', '-', '/', '**', '*']
37+
math_operations = {
38+
'+': add,
39+
'-': subtract,
40+
'*': multiply,
41+
'/': divide,
42+
'**': power
43+
}

0 commit comments

Comments
 (0)