News for hackers. Stuff that matters.
Re:The Concepts Get Harder (Python in 30 Days - Day 12) by ashray on Monday August 27, 2012 @12:58PM (#4439688)
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!
Re:The Concepts Get Harder (Python in 30 Days - Day 12) by rodriguezcommaj on Monday August 27, 2012 @01:02PM (#4439713)
Ha, 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.

Re:The Concepts Get Harder (Python in 30 Days - Day 12) by SiVal on Monday August 27, 2012 @04:56PM (#4440871)
Jason, 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.

Re:The Concepts Get Harder (Python in 30 Days - Day 12) by ashray on Monday August 27, 2012 @04:27PM (#4440694)
Meta 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.

Re:The Concepts Get Harder (Python in 30 Days - Day 12) by JulianWasTaken on Monday August 27, 2012 @01:44PM (#4439888)
Can't tell if he was serious or not, but metaclasses have no place in a 30 day quest to learn Python.
Re:The Concepts Get Harder (Python in 30 Days - Day 12) by rodriguezcommaj on Monday August 27, 2012 @01:54PM (#4439935)
That'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.

Re:The Concepts Get Harder (Python in 30 Days - Day 12) by danso on Monday August 27, 2012 @02:44PM (#4440173)
At 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.
Re:The Concepts Get Harder (Python in 30 Days - Day 12) by slurgfest on Monday August 27, 2012 @01:06PM (#4439742)
Meta 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
Re:The Concepts Get Harder (Python in 30 Days - Day 12) by rodriguezcommaj on Monday August 27, 2012 @01:17PM (#4439784)
Anyone 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?
Re:The Concepts Get Harder (Python in 30 Days - Day 12) by JulianWasTaken on Monday August 27, 2012 @01:46PM (#4439902)
A 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.

Note that as I said, I would suggest you completely ignore this and not even bother reading that right now.

Re:The Concepts Get Harder (Python in 30 Days - Day 12) by phaylon on Monday August 27, 2012 @01:49PM (#4439913)
I'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

Re:The Concepts Get Harder (Python in 30 Days - Day 12) by grifaton on Monday August 27, 2012 @02:13PM (#4440022)
I'm afriad this doesn't make much sense from a Python point of view, where a metaclass is a very specific language construct. For more details, you can't do much better than the StackOverflow answer that JulianWasTaken has linked to.
Re:The Concepts Get Harder (Python in 30 Days - Day 12) by phaylon on Monday August 27, 2012 @02:26PM (#4440092)
Ah, thanks. It seems to be in the same league, but in a different context. Gotta remember that they're different for the future.
Re:The Concepts Get Harder (Python in 30 Days - Day 12) by danso on Monday August 27, 2012 @01:44PM (#4439889)
This is a very helpful post. I teach beginners and one of my theories has been: you "just" need to understand for-loops, if-statements, and of course, how to invoke methods...and then you're going to finally understand why programming is worth it.

But those fundamental concepts are not at all "just" easy to grasp for some reason. I don't know if it is just the particular syntax or what. So it's very helpful to have a learner explain the difficulty.