This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cryptography.hazmat.backends import default_backend | |
from cryptography.hazmat.primitives.asymmetric import rsa | |
from cryptography.hazmat.primitives import serialization | |
from cryptography.hazmat.primitives import hashes | |
from cryptography.hazmat.primitives.asymmetric import padding | |
private_key = rsa.generate_private_key( | |
public_exponent=65537, | |
key_size=2048, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fstring_function(): | |
f'{1 + 2 = }' | |
>>> dis.dis(fstring_function) | |
2 0 LOAD_CONST 1 ('1 + 2 = ') | |
2 LOAD_CONST 2 (3) | |
4 FORMAT_VALUE 2 (repr) | |
6 BUILD_STRING 2 | |
8 POP_TOP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> dis.dis(walrus_func) | |
2 0 BUILD_LIST 0 | |
2 LOAD_CONST 1 ((1, 2, 3)) | |
4 LIST_EXTEND 1 | |
6 STORE_FAST 0 (a) | |
3 8 LOAD_GLOBAL 0 (len) | |
10 LOAD_FAST 0 (a) | |
12 CALL_FUNCTION 1 | |
14 DUP_TOP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def walrus_func(): | |
a = [1, 2, 3] | |
if (n := len(a)) > 10: | |
print(f"List is too long ({n} elements, expected <= 10)") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = [10, 20] | |
for s in range(5): | |
print(s) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 0 LOAD_CONST 1 (10) | |
2 LOAD_CONST 2 (20) | |
4 BUILD_LIST 2 | |
6 STORE_FAST 0 (s) | |
3 8 LOAD_GLOBAL 0 (range) | |
10 LOAD_CONST 3 (5) | |
12 CALL_FUNCTION 1 | |
14 GET_ITER | |
>> 16 FOR_ITER 12 (to 30) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 0 LOAD_CONST 1 (10) | |
2 LOAD_CONST 2 (20) | |
4 BUILD_LIST 2 | |
6 STORE_FAST 0 (s) | |
3 8 LOAD_GLOBAL 0 (range) | |
10 LOAD_CONST 3 (5) | |
12 CALL_FUNCTION 1 | |
14 GET_ITER | |
>> 16 FOR_ITER 16 (to 34) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://twitter.com/raymondh/status/1284331532153286656?s=20 | |
s = [10, 20] | |
for s[0] in range(5): | |
print(s) | |
# Result: | |
[0, 20] | |
[1, 20] | |
[2, 20] | |
[3, 20] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img | |
from keras.models import Sequential | |
from keras.layers import Conv2D, MaxPooling2D, ZeroPadding2D | |
from keras.layers import Activation, Dropout, Flatten, Dense | |
from keras import backend as K | |
from keras.callbacks import TensorBoard | |
import os | |
from shutil import copyfile | |
import shutil | |
import sys |
NewerOlder