You have named your script “random.py”. When you import random
, the script imports itself, not the random
module from the standard library. Since the import is recursive, random.random
also refers to the script, as does random.random.random
, etc.
To avoid this, don’t shadow built-in modules with your own.
2 Likes