Skip to content

Instantly share code, notes, and snippets.

@habibutsu
Last active December 24, 2015 16:39
Show Gist options
  • Save habibutsu/6829354 to your computer and use it in GitHub Desktop.
Save habibutsu/6829354 to your computer and use it in GitHub Desktop.
Different way to import in pythons
# Varaian 1
from package import module_with_some_name1, module_with_some_name2, \
module_with_some_name3, module_with_some_name4, module_with_some_name5, \
module_with_some_name6, module_with_some_name7
# Variant 2
from package import module_with_some_name1, \
module_with_some_name2, \
module_with_some_name3, \
module_with_some_name4, \
module_with_some_name5, \
module_with_some_name6, \
module_with_some_name7
# Variant 2 (alternative)
from package import (
module_with_some_name1,
module_with_some_name2,
module_with_some_name3,
module_with_some_name4,
module_with_some_name5,
module_with_some_name6,
module_with_some_name7
)
"""
For example - if need to delete 'module_with_some_name2' for first variant
we must do following steps:
1. delete module
2. perform reformat of imports with several deletions and insertions
for second varian - just delete it
After deleting diff between changes in first variant hard to read because you must view the entire line of imports
Recommendation in PEP8 http://www.python.org/dev/peps/pep-0008/#imports
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment