[Tutor] grid manager question

David bouncingcats at gmail.com
Tue Feb 14 00:32:41 EST 2023


On Tue, 14 Feb 2023 at 15:36, Phil <phillor9 at gmail.com> wrote:
> On 14/2/23 13:33, David wrote:

> > An App() class is one way to provide namespacing. It's not the only way.

> Thank you David for taking the time to reply, it's greatly appreciated.

No problem :)

> > If you are getting zero benefit from using an App() class, but it makes you
> > have to write 'self.' in front of oodles of variables where that otherwise
> > wouldn't be required, why clutter up your code with it?

> OOP programming offers several advantages and two that I can remember at
> the moment are:

> An app class can be extended to add new functionality.

Any code can also be extended to add new functionality.

> An app class can be used as a template. I try to create classes that can
> be imported into a new project.

Classes in general are great for importing, agreed. And subclassing.
However, you're unlikely to do either of those things to your App() class,
because it is your entire app. And your entire app will likely have some
parts that you never want to import or subclass, so that will prohibit doing
that at all, so this isn't a practical benefit in your context.

> I suppose another advantage is code reusability.

Same response as above. The benefits you are citing are well known
advantages of classes, that I use all the time. And it is good that you
know these facts. However these advantages are never going to be
applicable to the useless App() class that you are choosing to create.

The downside is that you have a ridulous amout of useless 'self.' all
over the place that interferes with your ability to see the simplicity of
what is happening underneath.

Instead of
  root = tk.Tk()

you have
  app = App()

combined with
  class App(tk.Tk)

which does exactly the same thing except now you have to write
'self.' a billion times for no benefit.

I realise that I'm arguing against commonly seen notions, but I am briefly
sticking my head out with absolutely nothing to gain because I believe
that they are inapplicable to what's being discussed here and now, and
I'm trying to help *you* at the point *you* are at *today*.

> > Anyway, I'm going to drop that topic now.

oops :)

Anyway, as I said, if my advice doesn't work for you then that's fine.
I will shut up. I'm not interested in debating these things. I'm just
trying to help, you. But, we might not be a good match for each
others preferences and teaching/learning styles. If you don't find
what I am telling you liberating, that's a sign that this conversation
is not going to be successful. Or if you'd rather trust a book than
a human, even when the human immediately shows you how to
do exactly what you asked for in the simplest possible way :)


More information about the Tutor mailing list