3

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?

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

Comments

0

You are importing main module which is in the same package that your file, you are doing a relative import (dot prefix). More on relative imports on PEP 328

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.