Skip to main content
Ctrl+K
Want to learn how to create a Python package? Go here!
pyOpenSci Open Source Lessons. The pyOpenSci logo is a purple flower with pyOpenSci under it. The o in open sci is the center of the flower pyOpenSci Open Source Lessons. The pyOpenSci logo is a purple flower with pyOpenSci under it. The o in open sci is the center of the flower
  • Write Better Code
  • Package & Share Code
  • Contribute Open Source
    • pyOpenSci Website
    • Peer Review Guide
    • Handbook
  • GitHub
  • Mastodon
  • Write Better Code
  • Package & Share Code
  • Contribute Open Source
  • pyOpenSci Website
  • Peer Review Guide
  • Handbook
  • GitHub
  • Mastodon

Section Navigation

Optimize Your Code with Functions, Conditionals and Handle Exceptions

  • Optimize your code
    • Why write functions?
    • Common Python exceptions
    • Conditional statements in Python
    • Conditional Statements With Alternative Conditions
    • Write Flexible Functions to Handle Messy Data
    • Write Multi-Parameter Functions
    • How to write a Python function

Write Better Cleaner Code

  • Write Clean, Modular, DRY Code
    • Clean, Modular Code: overview
    • Write DRY, modular Python code
    • Python code style for readability and usability
    • Make Your Code Easier to Read Using Expressive Variable Names in Python
    • Introduction to Pseudocode
    • Activity 1: Clean, Modular Code
    • Activity 2: DRY Code & Functions
    • Activity 3: Tests & Checks for your code
  • Write Clean, Better Code
  • Optimize your code

Optimize your code#

More here

previous

Write Clean, Better Code

next

Why write functions?

Edit on GitHub
Show Source

pyOpensci is dedicated to creating a welcoming, supportive and diverse community around the open source Python tools that drive open science. Our Code of Conduct defines expected behavior and guidelines that help create such a community.

© Copyright 2025, pyOpenSci.