Skip to content

Commit ad4899b

Browse files
committed
Cleanup, fstring format
1 parent 2f8d763 commit ad4899b

5 files changed

Lines changed: 15 additions & 31 deletions

File tree

‎Day-036/01-sys-reference_count.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@
88
import sys
99

1010
print("\nCreating a new list, `list_1`")
11-
list_1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
11+
list_1 = list(range(1, 10))
12+
print(f"list_1: {list_1}")
13+
# list_1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
1214

13-
print("Reference count of `list_1`: {}".format(sys.getrefcount(list_1)))
15+
print(f"Reference count of `list_1`: {sys.getrefcount(list_1)}")
1416

1517
print("\nAssigning a new reference (list_2) to `list_1`")
1618
list_2 = list_1
17-
print("Reference count of `list_1`: {}".format(sys.getrefcount(list_1)))
19+
print(f"Reference count of `list_1`: {sys.getrefcount(list_1)}")
1820

1921
print("\nAssigning a new reference (list_3) to `list_1`")
2022
list_3 = list_1
21-
print("Reference count of `list_1`: {}".format(sys.getrefcount(list_1)))
23+
print(f"Reference count of `list_1`: {sys.getrefcount(list_1)}")
2224

2325
print("\nDeleting reference lists, list_2 and list_3")
2426
del list_2
2527
del list_3
2628

27-
print("Reference count of `list_1`: {}".format(sys.getrefcount(list_1)))
29+
print(f"Reference count of `list_1`: {sys.getrefcount(list_1)}")

‎Day-036/02-sys-object_size.py‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,23 @@
99
for i in dir():
1010
print("{:>20} : {}".format(i, sys.getsizeof(i)))
1111

12-
12+
##
1313
print("\nCreating new objects.")
1414

1515
# Class
16-
17-
1816
class MyClass:
1917
pass
2018

2119

2220
# Function
23-
24-
2521
def my_func():
2622
pass
2723

2824

2925
# Lists:
3026
list_1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
3127

28+
##
3229
print("Getting a new object size listing:\n")
3330
for i in dir():
3431
print("{:>20} : {}".format(i, sys.getsizeof(i)))

‎Day-037/01-sys-sizeof_attrs.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ def test(self):
2323
my_class = MyClass()
2424
my_new_class = MyNewClass()
2525

26-
print("Size of class object w/o atts: {}".format(sys.getsizeof(my_class)))
27-
print("Size of class object with attrs: {}".format(sys.getsizeof(my_new_class)))
26+
if __name__ == "__main__":
27+
print(f"Script name: {sys.argv[0]}")
28+
print(f"Size of class object w/o atts: {sys.getsizeof(my_class)}")
29+
print(f"Size of class object with attrs: {sys.getsizeof(my_new_class)}")

‎Day-037/02-sys-getsizeof_attrs.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ def test(self):
2323
my_class = MyClass()
2424
my_new_class = MyNewClass()
2525

26-
print("Size of class object w/o atts: {}".format(sys.getsizeof(my_class)))
27-
print("Size of class object with attrs: {}".format(sys.getsizeof(my_new_class)))
26+
print(f"Size of class object w/o atts: {sys.getsizeof(my_class)}")
27+
print(f"Size of class object with attrs: {sys.getsizeof(my_new_class)}")

‎Day-037/02-sys-getsizeof_custom_attrs.py‎

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)