Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ".main" mean in python source code?

Tags:

python

In a source code in python: usr/local/lib/python3.3/unittest/__init__.py

from .result import TestResult
from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf,
                   skipUnless, expectedFailure)
from .suite import BaseTestSuite, TestSuite
from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
                     findTestCases)
from .main import TestProgram, main
from .runner import TextTestRunner, TextTestResult
from .signals import installHandler, registerResult, removeResult, removeHandler

I can't understand .result and .main. Why do they have a dot prefix in the name?

like image 658
cruelcage Avatar asked Jul 02 '26 13:07

cruelcage


1 Answers

It's called a relative import.

It means you import from the module in the same directory that the module this code is in. Without the dot, it would import the from first module found in the PYTHON PATH.

like image 119
e-satis Avatar answered Jul 05 '26 04:07

e-satis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!