Chirpy has come a long way—users can now create posts, like content, comment, and even have verified accounts. However, as our platform expands, we must ensure our code structure evolves as well.

Fixing private data members

Recall our lesson on “Encapsulation and Private Data Members,” where we learned that each private data member within a class should start with a leading underscore (_). While this convention doesn’t strictly prevent access in Python, it clearly communicates to other developers that these attributes aren’t intended for direct use. More importantly, this practice supports the principle of abstraction, which involves hiding internal implementation details and exposing only essential functionalities to the outside world.

Did you know?

By convention, all data members of a class should be treated as private.

Earlier, we applied this approach only to the password attribute. Now, it’s time to consistently adopt this convention across all data members in our Chirpy project. Let’s get started and refactor our code!

Create a free account to view this lesson.

Continue your learning journey with a 14-day free trial.

By signing up, you agree to Educative's Terms of Service and Privacy Policy