Combine multiple Python files into one
Combining two or more Python files into one is easy with Pyrfecter. Simply drag-and-drop Python files anywhere in this window and Pyrfecter will combine them into a single file. Then, with the click of a button, your new file will be fully linted, formatted, organized, and modernized.
Features
- Joins multiple files
- Groups imports at the top
- Removes duplicate imports
Limitations
The combined files may need to be tidied a little to remove duplicate variables.
For example, if we have two files named say_hi.py
and say_bye.py
:
# say_hi.py
import logging
logger = logging.getLogger(__name__)
def say_hi(name):
logger.debug("Saying hi")
print(f"Hi, {name}!")
# say_bye.py
import logging
logger = logging.getLogger(__name__)
def say_bye(name):
logger.debug("Saying bye")
print(f"Bye, {name}!")
The logger
variable will appear twice in the output:
import logging
logger = logging.getLogger(__name__)
def say_bye(name):
logger.debug("Saying bye")
print(f"Bye, {name}!")
logger = logging.getLogger(__name__)
def say_hi(name):
logger.debug("Saying hi")
print(f"Hi, {name}!")