Skip to content

sunilos/Python

Repository files navigation

Applied Python

Python tutorial example programs

Applied Python

  1. Basics
  2. Variable and Operators
  3. Control Statements
  4. Arrays and Collection
  5. Datetime
  6. Regular Expressions
  7. Functions
  8. OOP
  9. Classes and Object
  10. Exception Handling
  11. Modules
  12. I/O
  13. Multithreaded Programming
  14. Tkinter - Desktop app developement

Applied Advance Python

  1. Networking
  2. EMail
  3. Database connectivity - MYSQLDB
  4. CGI(Common Gateway Interface) Programming
  5. Web programming
  6. DJango

Tools

  1. Visual Studio Code

Naming convention

In Python, there are widely accepted naming conventions for program files to ensure consistency, readability, and compatibility with other Python modules and libraries. These conventions are based on the guidelines outlined in PEP 8, the Python Enhancement Proposal that defines Python's style guide. Here are the key conventions for naming Python program files:

1. Use All Lowercase Letters:

  • Python file names should be written in lowercase letters.
  • This avoids conflicts with systems that are case-sensitive (like some Unix-based systems).

Example:

  • my_program.py
  • data_analysis.py

2. Use Underscores to Separate Words:

  • If your file name contains multiple words, separate them with underscores (_) rather than using spaces, camelCase, or hyphens.

Example:

  • data_processing.py
  • user_authentication.py

3. Avoid Special Characters:

  • Avoid using special characters (such as @, #, $, etc.) in file names. Stick to alphanumeric characters and underscores.

Example:

  • Correct: data_cleaning.py
  • Incorrect: data@cleaning.py

4. Use Meaningful and Descriptive Names:

  • Choose file names that clearly describe the purpose or functionality of the script. This helps when the project contains multiple files.

Example:

  • image_converter.py for a script that converts image formats.
  • email_sender.py for a script that sends emails.

5. File Extension .py:

  • Python program files should always use the .py extension, which stands for Python.

Example:

  • main.py
  • utils.py

6. Avoid Starting File Names with Numbers:

  • Although it is technically allowed, it's better to avoid starting file names with numbers. This keeps your files more readable and reduces confusion.

Example:

  • Correct: chapter_one.py
  • Incorrect: 1_chapter.py

7. Avoid Conflicts with Standard Library Names:

  • Be cautious when naming your Python files. Avoid naming them after Python’s standard library modules, such as math.py, datetime.py, string.py, etc., to prevent import conflicts.

Example:

  • Correct: math_operations.py
  • Incorrect: math.py

8. When Writing Python Packages:

  • If your file is intended to be part of a Python package, the package folder should include an __init__.py file (which can be empty or include initialization code).
  • Package names are generally lowercase as well.

Example:

  • my_package/__init__.py

Examples of Good File Names:

  • data_cleaning.py
  • process_images.py
  • user_auth.py
  • calculate_metrics.py

By following these naming conventions, your Python files will be more organized, readable, and in line with the broader Python community standards.

About

Python example programs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •