[Solved] Use of . in python? [duplicate]


You use dot for 3 main reasons:

  1. Accessing members of a module: a module is simply a python file, and members can be variables, functions, classes and so on.

  2. Accessing modules within a package: a package is a directory containing a__init__ module. Some packages are nested and contain inner packages. You have to reach the innermost and then the module. For both you use dot syntax.

  3. And at last, accessing members of a class, for example method (functions) fields (variables) and so on.

In your above code random is a Python module and you are accessing its function randint.

solved Use of . in python? [duplicate]