4 ms·
I can't wait to see the part where you get to meta classes. That's when the real fun shall begin :D Still, an inspiring series for python beginners. Keep it up!
by ashray 14y ago
I can't wait to see the part where you get to meta classes. That's when the real fun shall begin :D Still, an inspiring series for python beginners. Keep it up!
- rodriguezcommaj 14y agoHa, I don't know if that's a threat or a friendly challenge! I will take the latter. I am looking forward to harder programming concepts, I just need to keep practicing to drill them into my head. Thanks for the words of encouragement, I will definitely keep working away at it.
- JulianWasTaken 14y agoCan't tell if he was serious or not, but metaclasses have no place in a 30 day quest to learn Python.
- rodriguezcommaj 14y agoThat's the feeling that I am getting. I like being introduced to concepts early on, even if I don't fully grasp them. Somewhere down the line though, I will see something more advanced and go, "OH! Meta classes. I kind of know about those!" and it is pretty helpful. It works kind of like that learning by immersion (especially for languages), where you are just in the thick of it and sooner or later things start to make more sense. I agree that it's an advanced concept, but it helps when people post stuff like that here and explain it so that I am at least familiar with it existing.
- danso 14y agoAt my college, general OOP concepts weren't even in the first semester of the com sci introductory course. Sure, that didn't lend itself to a lot of cool projects, but looking back, pointers, functions, and arrays are definitely time-consuming to fully grok.
- ashray 14y agoMeta classes are pretty interesting creatures and they allow you to generate custom classes at runtime which can be quite useful. I didn't mean that you'd get to them in 30 days but if you really like Python and eventually come around to developing fairly complex applications - you might need them. Django's ORM is a pretty good example of some great meta classery. The stack overflow question posted earlier is a good resource that you should bookmark so that you can look at it when you actually come across some meta classes.
- SiVal 14y agoJason, be very careful about putting much weight on comments from programmers. When you get a bunch of guys (mostly guys) with the same skill together in one place, they'll tend to start spouting machoisms to show off. Programmers will say things like, "You don't really understand X until you can do <something I just learned to do>" or "You're not a REAL programmer until you <abandon some modern convenience in favor of the programming equivalent of stone knives>" or whatever. Ignore it. Programming is like any other skill, where mastering the fundamentals is the heart of it. There are a LOT of basic concepts---basic and composite data types and data structures, the difference between a thing and some kind of pointer to a thing, ways of repeating operations (looping or recursion), breaking big problems into small ones and building back up to the big, being aware of causes, symptoms, and cures for common errors (off-by-one bug, overflowing an int, testing floating point nums with equals, etc.) What matters most is training these basic ideas into reflexes and learning to easily match combinations of these basics to most problems you encounter. Learn the basics, then tackle lots of fairly simple, common programming tasks (google for sites that offer lots of programming exercises) until those basics become part of you. You should also work on "fun" projects of your own at the same time so it won't get boring. Forget the arcane and obscure features and techniques for a while. They won't make you a great programmer; mastery of the fundamentals will.
- slurgfest 14y agoMeta classes have a few uses but for the most part, they should not be seen in a codebase. Good to understand, better not to use... because the likelihood is that nobody who needs to use your code also wants to waste time understanding your metaclass magic
- rodriguezcommaj 14y agoAnyone want to explain meta classes for me? Without knowing anything from the start, I would think that they are some subset of classes, maybe they inherit from some built-in classes in Python? I'm somewhat familiar with what classes are - a defined object that has certain characteristics that describe it and store information about it, as well as methods that can be used on that object. I always think of a rocketship class that might have a size, color, velocity, health, fuel, etc. and then have methods like accelerate, decelerate, rotate, shoot, etc. How do meta classes differ?
- JulianWasTaken 14y agoA metaclass is simply the class of a class. Rather than elaborating on that, there's a stack overflow answer that's often linked that is uncharacteristically decent at explaining here: http://stackoverflow.com/a/6581949/637787 http://stackoverflow.com/a/6581949/637787. Note that as I said, I would suggest you completely ignore this and not even bother reading that right now.
- phaylon 14y agoI'm not a Python developer, but in general metaclasses are classes represented as objects. You can also have objects for methods, attributes, and whatever else your object system provides. These objects of course also have classes that you can subclass and extend, apply traits to, and so on. This is very useful for introspection and dynamically building class structures. Which extends to it being also a common API for extensions to your classes (I'm playing with a Perl/Glib project using the Moose MOP framework to allow Perl classes to have Glib signals, for example). Speaking for Perl/Moose, it's regularly used to modify or extend the behavior/capabilities of attributes (by applying traits to them). Even just the introspective aspect means your program can easily know about the structure of your classes, for serializations, debugging, proxying, auto-generating documentation, auto-generating command line arguments, and so on. This is just a rough outline, and in no way complete. I'd guess here's a good language-agnostic starting point: http://en.wikipedia.org/wiki/Metaobject http://en.wikipedia.org/wiki/Metaobject