Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 13_OOP/e_DataClasses/04_data_classes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import random
from dataclasses import dataclass, field
import secrets


def random_price():
return random.randint(20, 100)
return secrets.SystemRandom().randint(20, 100)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace random.{func} with more secure secrets library functions.



@dataclass
Expand All @@ -25,4 +25,4 @@ class Book(object):
# thus, provides the value dynamically, when the new instance is created.

c = Book("Python programming", "David Beazley", 45)
print(vars(c))
print(vars(c))