Skip to content

A comprehensive learning resource for junior engineers to master Python best practices and code quality

Notifications You must be signed in to change notification settings

thabils/python-code-quality

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Code Quality Training Repository

Welcome to the Python Code Quality Training Repository! This resource is designed to help junior engineers master clean, Pythonic code and professional development practices.

🎯 Objectives

By working through this repository, you will:

  • Write idiomatic Python code that follows community standards
  • Master naming conventions that make code self-documenting
  • Structure code using classes and OOP principles where appropriate
  • Write effective tests using pytest and modern testing practices
  • Develop habits that lead to maintainable, readable code

📚 Repository Structure

python-code-quality/
├── guides/              # Comprehensive guides with examples
│   ├── 01_pythonic_code.md
│   ├── 02_naming_conventions.md
│   ├── 03_oop_and_classes.md
│   ├── 04_testing.md
│   └── examples/        # Code examples demonstrating concepts
├── exercises/           # Hands-on coding exercises
│   ├── 01_pythonic_code/
│   ├── 02_naming_conventions/
│   ├── 03_oop_patterns/
│   └── 04_testing/
└── solutions/           # Reference solutions (try exercises first!)

🚀 Getting Started

  1. Read the Guides: Start with the guides in order. Each builds on previous concepts.

    • Guide 1: Pythonic Code Practices
    • Guide 2: Naming Conventions
    • Guide 3: OOP and Class Structure
    • Guide 4: Testing with pytest
  2. Study Examples: Review the code examples in guides/examples/ to see concepts in action.

  3. Complete Exercises: Work through exercises for each topic. Try to solve them without looking at solutions!

  4. Check Solutions: After attempting exercises, compare your solutions with the reference implementations.

  5. Apply in Real Projects: Use these principles in your daily work.

📖 Learning Path

Module 1: Pythonic Code (Week 1-2)

Learn Python idioms and best practices that make your code more readable and efficient.

  • List comprehensions and generator expressions
  • Context managers and the with statement
  • Pythonic iteration patterns
  • Duck typing and EAFP principle
  • Decorators and property usage

Module 2: Naming Conventions (Week 3)

Master the art of naming variables, functions, classes, and modules.

  • PEP 8 naming standards
  • Meaningful and intention-revealing names
  • Avoiding abbreviations and cryptic names
  • Naming booleans, collections, and functions
  • Module and package naming

Module 3: OOP and Class Structure (Week 4-5)

Learn when and how to use classes effectively in Python.

  • When to use classes vs functions
  • Single Responsibility Principle
  • Composition over inheritance
  • Data classes and named tuples
  • Abstract base classes and protocols

Module 4: Testing with pytest (Week 6-7)

Master testing practices to write robust, maintainable code.

  • Writing effective unit tests with pytest
  • Using fixtures for test setup and teardown
  • Mocking external dependencies
  • Parametrized tests for multiple scenarios
  • Test-driven development (TDD) basics
  • Achieving good test coverage

🎓 Best Practices Checklist

Before submitting any code for review, ask yourself:

  • Is my code Pythonic? (EAFP, comprehensions, context managers)
  • Are all names clear and self-documenting?
  • Have I avoided single-letter variables (except in comprehensions)?
  • Are my functions focused and doing one thing?
  • Have I used classes appropriately (not over-engineering)?
  • Does my code follow PEP 8 style guidelines?
  • Have I added docstrings to functions and classes?
  • Is my code DRY (Don't Repeat Yourself)?
  • Have I written tests for my code?
  • Are my tests independent and repeatable?

🔧 Tools and Resources

Recommended Tools:

  • pytest - Testing framework
  • pytest-cov - Code coverage tool
  • pylint - Static code analyzer
  • black - Code formatter
  • mypy - Type checker
  • isort - Import sorter

Setup:

pip install pytest pytest-cov pylint black mypy isort

Run checks:

# Testing
pytest tests/ -v
pytest --cov=src tests/

# Code quality
black --check your_file.py
pylint your_file.py
mypy your_file.py
isort --check your_file.py

📚 Additional Resources

💬 Getting Help

If you're stuck on an exercise or concept:

  1. Re-read the relevant guide section
  2. Study the examples in guides/examples/
  3. Review the Zen of Python: python -c "import this"
  4. Ask a senior engineer for guidance
  5. Check solutions as a last resort (learn from them, don't just copy!)

🌟 Code Review Standards

At Atlassian, we value:

  • Readability over cleverness - Code is read more than written
  • Simplicity over complexity - Simple solutions are better
  • Consistency - Follow team conventions
  • Documentation - Code should be self-documenting, comments explain why
  • Testing - Write testable, tested code

Happy coding! Remember: writing clean code is a skill that improves with practice. 🐍✨

About

A comprehensive learning resource for junior engineers to master Python best practices and code quality

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages