topic: File and directory naming in Python

Tags File and directory naming python
Hard Prerequisites
IMPORTANT: Please review these prerequisites, they include important information that will help you with this content.
  • FILE-AND-DIRECTORY-NAMING: File and directory naming
  • How should I name my Python modules and packages?

    When naming files and directories in Python, you should use small letters and underscores to separate your words. This type of naming convention is called snake_case and is also used in naming Python variable and function names.

    Do you think you’ve got it?

    Directories

    Based on the above guidelines, which of the following is a good way to name a Python directory?

      - apyhthondirectory
    
      - a_python_directory
    
      - a-python-directory
    
      - APYTHONDIRECTORY
    
      - ApythonDirectory
    

    We are curious as to what your answer was! See below for some tips in naming your directories.

      - good_directory_name
    
      - bad-directory-name
    
      - AnotherBadDirectoryName
    
      - AVERYBADDIRECTORYNAME
    
      - nevernameyourdirectorylikethis
    

    Files

    Test yourself again - do any of the examples below follow the recommended Python naming guidelines?

    - task.python
    
    - task-1.1.py
    
    - task1.1.py
    
    - python-module.py
    
    - my_file .py
    

    In case you found the above a bit tricky, see a few more rule abiding file names below.

     - task_1.py
    
     - task_1_1.py
    
     - good_python_file.py
    
     - keep_it_short.py
    
     - must_be_meaningful.py
    

    RAW CONTENT URL