I am a beginner in Python and found a strange phenomenon that some methods in Python standard library can be called as functions.
For example, there is a method randint() defined in Class Random in module random.py.
As I understand, when we wanted to call it, we should import the module random first, then declare a instance of class Random so that method randint() can be called such as
import random as rd
aaa = rd.Random()
aaa.randint()
But I just find that randint() can be called as a function and it is unnecessary to do as above:
import random as rd
rd.randint()
So I wonder how does this illogical phenomenon happen?
Why can methods in Python standard library be called as functions?
New contributor