0

There are some statements in the init.py file of python DEAP package, such as:

from .crossover import *

Is this means import all function from crossover.py? So why there is a "." in front of crossover. It would be so much appreciated that if somebody could help me understand the meaning of . and * in the statement.

Zhida Deng
  • 189
  • 2
  • 12
  • the `.` means your current directory is probably a python package (contains a `__init__.py` file) and that `crossover.py` is probably in the same directory as the file you're in. The `*` means import everything in that file. – castis Jun 16 '17 at 14:16
  • Thanks. It actually duplicates with the one you referred. – Zhida Deng Jun 16 '17 at 14:34

1 Answers1

0

Python imports names from files and gives you access to them in the interpreter or other files. This is all a part of the Module system used in Python.

The star (asterisk) means "add all of the names from that file to my current working list of names."

The '.' in front of crossover is a relative import. This means, relative to your current location (in an interpreter or a file) find a file called "crossover"

All together:

Import all of the names of in a module called crossover that is located within the current directory.

theWanderer4865
  • 861
  • 13
  • 20