In Python code in the project micropython
, sometimes the import
statements are inside of functions.
def main():
import argparse
cmd_parser = argparse.ArgumentParser(description='A tool to work with MicroPython .mpy files.')
cmd_parser.add_argument('-d', '--dump', action='store_true',
help='dump contents of files')
cmd_parser.add_argument('-f', '--freeze', action='store_true',
help='freeze files')
...
Is this good practice?
Is there a technical reason for this?