GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Pyupgrade to python3.8 (#3616) · jusing-es/Python@9b95e4f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • DIRECTORY.md
  • ciphers
    • simple_substitution_cipher.py
    • xor_cipher.py
  • compression
    • lempel_ziv.py
    • lempel_ziv_decompress.py
  • data_structures
    • binary_tree
      • segment_tree_other.py
    • heap
      • heap.py
    • linked_list
      • deque_doubly.py
  • graphs
    • minimum_spanning_tree_boruvka.py
  • machine_learning
    • astar.py
    • k_means_clust.py
  • maths
    • entropy.py
    • numerical_integration.py
  • project_euler
    • problem_013
      • sol1.py
    • problem_018
      • solution.py
    • problem_042
      • solution42.py
    • problem_049
      • sol1.py
    • problem_054
      • sol1.py
      • test_poker_hand.py
    • problem_063
      • sol1.py
    • problem_067
      • sol1.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎DIRECTORY.md‎

Copy file name to clipboardExpand all lines: DIRECTORY.md
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@
323323
* [Sdbm](https://github.com/TheAlgorithms/Python/blob/master/hashes/sdbm.py)
324324
* [Sha1](https://github.com/TheAlgorithms/Python/blob/master/hashes/sha1.py)
325325

326+
## Knapsack
327+
* [Knapsack](https://github.com/TheAlgorithms/Python/blob/master/knapsack/knapsack.py)
328+
* [Test Knapsack](https://github.com/TheAlgorithms/Python/blob/master/knapsack/test_knapsack.py)
329+
326330
## Linear Algebra
327331
* Src
328332
* [Lib](https://github.com/TheAlgorithms/Python/blob/master/linear_algebra/src/lib.py)
@@ -502,6 +506,7 @@
502506
* [Magicdiamondpattern](https://github.com/TheAlgorithms/Python/blob/master/other/magicdiamondpattern.py)
503507
* [Markov Chain](https://github.com/TheAlgorithms/Python/blob/master/other/markov_chain.py)
504508
* [Max Sum Sliding Window](https://github.com/TheAlgorithms/Python/blob/master/other/max_sum_sliding_window.py)
509+
* [Median Of Two Arrays](https://github.com/TheAlgorithms/Python/blob/master/other/median_of_two_arrays.py)
505510
* [Nested Brackets](https://github.com/TheAlgorithms/Python/blob/master/other/nested_brackets.py)
506511
* [Palindrome](https://github.com/TheAlgorithms/Python/blob/master/other/palindrome.py)
507512
* [Password Generator](https://github.com/TheAlgorithms/Python/blob/master/other/password_generator.py)
Collapse file

‎ciphers/simple_substitution_cipher.py‎

Copy file name to clipboardExpand all lines: ciphers/simple_substitution_cipher.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def main():
1818
mode = "decrypt"
1919
translated = decryptMessage(key, message)
2020

21-
print("\n{}ion: \n{}".format(mode.title(), translated))
21+
print(f"\n{mode.title()}ion: \n{translated}")
2222

2323

2424
def checkValidKey(key: str) -> None:
Collapse file

‎ciphers/xor_cipher.py‎

Copy file name to clipboardExpand all lines: ciphers/xor_cipher.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ def encrypt_file(self, file: str, key: int = 0) -> bool:
141141
assert isinstance(file, str) and isinstance(key, int)
142142

143143
try:
144-
with open(file, "r") as fin:
144+
with open(file) as fin:
145145
with open("encrypt.out", "w+") as fout:
146146

147147
# actual encrypt-process
148148
for line in fin:
149149
fout.write(self.encrypt_string(line, key))
150150

151-
except IOError:
151+
except OSError:
152152
return False
153153

154154
return True
@@ -166,14 +166,14 @@ def decrypt_file(self, file: str, key: int) -> bool:
166166
assert isinstance(file, str) and isinstance(key, int)
167167

168168
try:
169-
with open(file, "r") as fin:
169+
with open(file) as fin:
170170
with open("decrypt.out", "w+") as fout:
171171

172172
# actual encrypt-process
173173
for line in fin:
174174
fout.write(self.decrypt_string(line, key))
175175

176-
except IOError:
176+
except OSError:
177177
return False
178178

179179
return True
Collapse file

‎compression/lempel_ziv.py‎

Copy file name to clipboardExpand all lines: compression/lempel_ziv.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def read_file_binary(file_path: str) -> str:
1717
with open(file_path, "rb") as binary_file:
1818
data = binary_file.read()
1919
for dat in data:
20-
curr_byte = "{0:08b}".format(dat)
20+
curr_byte = f"{dat:08b}"
2121
result += curr_byte
2222
return result
23-
except IOError:
23+
except OSError:
2424
print("File not accessible")
2525
sys.exit()
2626

@@ -105,7 +105,7 @@ def write_file_binary(file_path: str, to_write: str) -> None:
105105

106106
for elem in result_byte_array:
107107
opened_file.write(int(elem, 2).to_bytes(1, byteorder="big"))
108-
except IOError:
108+
except OSError:
109109
print("File not accessible")
110110
sys.exit()
111111

Collapse file

‎compression/lempel_ziv_decompress.py‎

Copy file name to clipboardExpand all lines: compression/lempel_ziv_decompress.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ def read_file_binary(file_path: str) -> str:
1616
with open(file_path, "rb") as binary_file:
1717
data = binary_file.read()
1818
for dat in data:
19-
curr_byte = "{0:08b}".format(dat)
19+
curr_byte = f"{dat:08b}"
2020
result += curr_byte
2121
return result
22-
except IOError:
22+
except OSError:
2323
print("File not accessible")
2424
sys.exit()
2525

@@ -76,7 +76,7 @@ def write_file_binary(file_path: str, to_write: str) -> None:
7676

7777
for elem in result_byte_array[:-1]:
7878
opened_file.write(int(elem, 2).to_bytes(1, byteorder="big"))
79-
except IOError:
79+
except OSError:
8080
print("File not accessible")
8181
sys.exit()
8282

Collapse file

‎data_structures/binary_tree/segment_tree_other.py‎

Copy file name to clipboardExpand all lines: data_structures/binary_tree/segment_tree_other.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from queue import Queue
88

99

10-
class SegmentTreeNode(object):
10+
class SegmentTreeNode:
1111
def __init__(self, start, end, val, left=None, right=None):
1212
self.start = start
1313
self.end = end
@@ -17,10 +17,10 @@ def __init__(self, start, end, val, left=None, right=None):
1717
self.right = right
1818

1919
def __str__(self):
20-
return "val: %s, start: %s, end: %s" % (self.val, self.start, self.end)
20+
return f"val: {self.val}, start: {self.start}, end: {self.end}"
2121

2222

23-
class SegmentTree(object):
23+
class SegmentTree:
2424
"""
2525
>>> import operator
2626
>>> num_arr = SegmentTree([2, 1, 5, 3, 4], operator.add)
Collapse file

‎data_structures/heap/heap.py‎

Copy file name to clipboardExpand all lines: data_structures/heap/heap.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/python3
22

33

4-
class Heap(object):
4+
class Heap:
55
"""
66
>>> unsorted = [103, 9, 1, 7, 11, 15, 25, 201, 209, 107, 5]
77
>>> h = Heap()
Collapse file

‎data_structures/linked_list/deque_doubly.py‎

Copy file name to clipboardExpand all lines: data_structures/linked_list/deque_doubly.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self, link_p, element, link_n):
2020
self._next = link_n
2121

2222
def has_next_and_prev(self):
23-
return " Prev -> {0}, Next -> {1}".format(
23+
return " Prev -> {}, Next -> {}".format(
2424
self._prev is not None, self._next is not None
2525
)
2626

Collapse file

‎graphs/minimum_spanning_tree_boruvka.py‎

Copy file name to clipboardExpand all lines: graphs/minimum_spanning_tree_boruvka.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def build(vertices=None, edges=None):
9999
g.add_edge(*edge)
100100
return g
101101

102-
class UnionFind(object):
102+
class UnionFind:
103103
"""
104104
Disjoint set Union and Find for Boruvka's algorithm
105105
"""
Collapse file

‎machine_learning/astar.py‎

Copy file name to clipboardExpand all lines: machine_learning/astar.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import numpy as np
1414

1515

16-
class Cell(object):
16+
class Cell:
1717
"""
1818
Class cell represents a cell in the world which have the property
1919
position : The position of the represented by tupleof x and y
@@ -45,7 +45,7 @@ def showcell(self):
4545
print(self.position)
4646

4747

48-
class Gridworld(object):
48+
class Gridworld:
4949
"""
5050
Gridworld class represents the external world here a grid M*M
5151
matrix

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.