Skip to content

Files

Latest commit

 

History

History
34 lines (20 loc) · 709 Bytes

File metadata and controls

34 lines (20 loc) · 709 Bytes

Pattern: Malformed module level import placement

Issue: -

Description

All module level imports should be at the top of the file. This means that there should be no statements in between module level imports.

Example of incorrect code:

In this example, the sys import is not at the top of the file because local.setlocale occurs before it.

import locale

locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

import sys

Example of correct code:

Change the code so that the method call occurs after the imports.

import locale
import sys

locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

Further Reading