0

using the package layout here:

sound/                          Top-level package
      __init__.py               Initialize the sound package
      formats/                  Subpackage for file format conversions
              __init__.py
              wavread.py
              wavwrite.py
              aiffread.py
              aiffwrite.py
              auread.py
              auwrite.py
              ...
      effects/                  Subpackage for sound effects
              __init__.py
              echo.py
              surround.py
              reverse.py
              ...
      filters/                  Subpackage for filters
              __init__.py
              equalizer.py
              vocoder.py
              karaoke.py
              ...

it seems i can do both:

from sound.effects import echo

and

import sound.effects.echo as echo

what is the difference between these 2 syntaxes?


edit. a difference i have found is:

import sound.effects
del sound.effects
from sound.effects import echo              # ok
from sound.effects import echo as echo      # ok
import sound.effects.echo                   # ok
import sound.effects.echo as echo           # fail

this was tested on python 3.6; on python 3.7 all are ok;

Cyker
  • 9,946
  • 8
  • 65
  • 93

0 Answers0