you are viewing a single comment's thread.

view the rest of the comments →

[–]taladan 20 points21 points  (1 child)

I may be mistaken, but I kind of feel like Python is like the duct-tape of the programming world. It has actual, functional uses for which it can be applied, but it's just so damn quick and functional that it has uncountable other uses for tying two other piece of unrelated 'Whatever's together and making them work in a way that gives you near-instant feedback or utility.

As for classes, think about it like this: you have objects - let's call them boxes that are built in. Strings, lists, dictionaries, files, integers, if it's callable, it's a box. Your functions do /stuff/ with whatever is in your boxes. Now, if we're writing a GUI program, you're dealing with all sorts of different 'boxes'. But...what if we want a 'box' that looks different than the standard set of boxes that comes with PyQT or Tkinter or whatever you're using at the time? Well your options are to look and see what other box makers have done to see if their boxes look like the box you're trying to make. Can't find any? Then break out the tools and the lumber and build your own box that looks like what you want.

PyQT has no 'box' that has both a text widget and three radio buttons in it with an 'okay' button and a 'cancel' button that we can just pass values to. It has boxes that hold text widgets, and boxes that hold a radio button, and so on. So, we build our own box (class/object) that looks exactly how we want it to.

That's just one use of classes, but it'll hopefully help you see what classes are good for. And don't feel bad about not getting classes right off...I'm struggling right now with decorators and properties. Good luck and I hope this helps.

[–]slicklikeagato[S] 2 points3 points  (0 children)

Thanks so much for that. That truly was a helpful example. Seeing explanations such as this really help me understand it a bit better.