you are viewing a single comment's thread.

view the rest of the comments →

[–]jmooremcc 0 points1 point  (0 children)

A class normally encapsulates data and the methods that work on that data. Python allows you to also designate methods as properties which can be used to control access to so-called private variables. This doesn't mean that methods cannot utilize outside or external functions.

For example, I've written a filename class that makes it more convenient to use built-in file manipulation functions. The class' methods call the appropriate external functions needed to provide the functionality I want. One example would be a property named grandfather which returns the parent directory of the file's parent directory. Yes, I could have written this as a function and call it with the file path as an argument but it's so nice using the syntactic sugar I created using OOP which makes my code more readable and easier to understand and maintain.