Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Refactoring: Prepare Your Code to Get Help (Summary)

Congratulations! The next time you run into trouble while programming, you’ll be able to get quality answers by asking a clear question and presenting your helper with code that’s accessible and executable.

In this video course, you’ve learned how to:

  • Write a clear, concise question using how or why
  • Remove obstacles and visual clutter from your code
  • Improve your code by refactoring
  • Raise and catch exceptions within nested functions

Now you’re ready to connect with fellow programmers and have your own code conversations. You can do just that by joining the Real Python community.

To learn more about the concepts covered in this course, check out:

Do you have any tips for programmers seeking answers to their coding questions? Share your advice in the comments below!

Download

Sample Code (.zip)

2.6 KB
Download

Course Slides (.pdf)

9.6 MB

00:00 Thank you so much for joining Real Python Code Conversations today.

00:05 In this course, you learned how to ask good questions to get help from other Python developers, how to make your code executable, how to clean up the code to focus on the problem you have, create functions and variables with generic yet descriptive names, and handle errors and use custom exceptions.

00:26 The question you saw today in this course was posted in our Real Python community Slack chat. It’s a great place to get help from other Real Python community members and the Real Python team.

00:37 If you want to get more immediate help, then Real Python office hours might be right up your alley. Every week for our subscribers, we hold an informal hangout session that we call Office Hours.

00:49 In these sessions, we hop on a video call and chat about anything Python- or programming-related.

00:57 If you want to expand your knowledge on the topics we tackled during this Code Conversation, let me recommend these Real Python tutorials for you. In Python Exceptions: An Introduction, you’ll learn what exceptions are good for in Python.

01:11 You’ll see how to raise exceptions and how to handle them with tryexcept blocks in LBYL vs EAFP: Preventing or Handling Errors in Python, you’ll learn about two popular coding styles in Python: Look Before You Leap and Easier to Ask Forgiveness Than Permission.

01:30 Understanding both styles will help you to deal with errors and exceptions in your code. Conditional Statements in Python is a step-by-step tutorial where you learn how to use if statements and write decision-making code in your Python programs.

01:47 In Defining Your Own Python Function, you’ll learn how to define and call your own Python function. You’ll also learn about passing data to your function and returning data from your function back to its calling environment.

01:59 If you want to get more specific, then Defining Main Functions in Python is just for you. In this step-by-step tutorial, you’ll learn how Python main functions are used and some best practices to organize your code so it can be executed as a script and imported from another module. Remember when Martin defined a custom error class?

02:20 He basically sneaked in another topic in this Code Conversation: object-oriented programming. In the tutorial we have on object-oriented programming, you learn the basics of object-oriented programming and cover concepts like classes and inheritance.

02:39 I hope these resources will keep you busy while we continue to produce more Python tutorials for you. Thanks for watching this episode of Real Python Code Conversations.

02:48 My name is Philipp. See you next time.

Become a Member to join the conversation.