Moving to an OOP model from an classically imperitive one

Ian Kelly ian.g.kelly at gmail.com
Wed Apr 23 17:23:24 EDT 2014


On Apr 23, 2014 5:01 PM, <tim.thelion at gmail.com> wrote:
> I asked on IRC and it was sugested that I use multiple classes, however I
see no logical way to separate a SubuserProgram object into multiple
classes.

You say you already have the methods logically separated into files. How
about adding one abstract class per file, and then letting SubuserProgram
inherit from each of those individual classes?

As another alternative that you haven't mentioned yet, you could create a
decorator to be applied to each method, which will inject it into the class
at the time it is defined. The explicitness of the decorator solves your
confusion problem of "why does this function use self". It creates a couple
of new problems though: 1) reading the class won't tell you what methods it
contains; and 2) making sure the class is fully constructed before it is
used becomes tricky.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140423/1ee5ad1d/attachment.html>


More information about the Python-list mailing list