Simplify code by dropping support for legacy Python (#1143) · devdave/Python_TheAlgorithms@47a9ea2 · GitHub
Skip to content

Commit 47a9ea2

Browse files
authored
Simplify code by dropping support for legacy Python (TheAlgorithms#1143)
* Simplify code by dropping support for legacy Python * sort() --> sorted()
1 parent 32aa7ff commit 47a9ea2

145 files changed

Lines changed: 367 additions & 976 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 10 additions & 10 deletions

ciphers/affine_cipher.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
import sys, random, cryptomath_module as cryptoMath
32

43
SYMBOLS = r""" !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"""

ciphers/atbash.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
1-
try: # Python 2
2-
raw_input
3-
unichr
4-
except NameError: # Python 3
5-
raw_input = input
6-
unichr = chr
7-
8-
9-
def Atbash():
1+
def atbash():
102
output=""
11-
for i in raw_input("Enter the sentence to be encrypted ").strip():
3+
for i in input("Enter the sentence to be encrypted ").strip():
124
extract = ord(i)
135
if 65 <= extract <= 90:
14-
output += unichr(155-extract)
6+
output += chr(155-extract)
157
elif 97 <= extract <= 122:
16-
output += unichr(219-extract)
8+
output += chr(219-extract)
179
else:
18-
output+=i
10+
output += i
1911
print(output)
2012

2113

2214
if __name__ == '__main__':
23-
Atbash()
15+
atbash()

ciphers/brute_force_caesar_cipher.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
def decrypt(message):
32
"""
43
>>> decrypt('TMDETUX PMDVU')

ciphers/onepad_cipher.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import print_function
2-
31
import random
42

53

@@ -15,7 +13,7 @@ def encrypt(self, text):
1513
cipher.append(c)
1614
key.append(k)
1715
return cipher, key
18-
16+
1917
def decrypt(self, cipher, key):
2018
'''Function to decrypt text using psedo-random numbers.'''
2119
plain = []

ciphers/rabin_miller.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
# Primality Testing with the Rabin-Miller Algorithm
32

43
import random

ciphers/rot13.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
def dencrypt(s, n):
32
out = ''
43
for c in s:

ciphers/rsa_cipher.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
import sys, rsa_key_generator as rkg, os
32

43
DEFAULT_BLOCK_SIZE = 128
@@ -16,7 +15,7 @@ def main():
1615
if mode == 'encrypt':
1716
if not os.path.exists('rsa_pubkey.txt'):
1817
rkg.makeKeyFiles('rsa', 1024)
19-
18+
2019
message = input('\nEnter message: ')
2120
pubKeyFilename = 'rsa_pubkey.txt'
2221
print('Encrypting and writing to %s...' % (filename))

ciphers/rsa_key_generator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
import random, sys, os
32
import rabin_miller as rabinMiller, cryptomath_module as cryptoMath
43

ciphers/simple_substitution_cipher.py

Lines changed: 2 additions & 3 deletions

0 commit comments

Comments
 (0)