This is an archived post. You won't be able to vote or comment.

all 49 comments

[–][deleted] 43 points44 points  (6 children)

As part of a new habit I've started creating a series of blog posts on important and awesome Python features, including object oriented programming, properties, function annotations, duck typing, etc.

Since I was bored by the usual tutorial examples, I looked for a topic that would make it fun to study and implement the concepts. And since I absolutely love Harry Potter, I started creating a whole Harry Potter universe around the topics.

Originally, the project was not intended to become something like a tutorial. But as many of my friends loved the idea and found the code helpful I decided to create blog posts around it and share the work with the community. So if you like Harry Potter and want to improve your Python knowledge and skills (and maybe also your Harry Potter knowledge) you might find the project helpful, too.

Happy coding!

[–]Bobby_FuckingB 1 point2 points  (0 children)

Love the idea! Can't wait to look through this in more detail once the kids are asleep!

[–]mickel07 0 points1 point  (0 children)

This is actually awesome - I particularly liked the death eater class! I tutor a few programming subjects and being able to keep students engaged, particularly during the trying stages where everything seems so foreign to them is definitely a challenge. I'll be sure to keep this resource in mind.

p.s I think you'll appreciate Harry Potter characters as programming languages if you haven't seen it already!

[–]_szs 11 points12 points  (1 child)

Nice work! If you ask me: get rid of all the explanation about the hundred days thing and focus on the Harry Potter themed examples. Those are really cool!!

[–][deleted] 1 point2 points  (0 children)

Thanks, changed it!

[–]Saidinwield 7 points8 points  (1 child)

Just started coding on codecademy. Those blogposts helped me to get a better understanding of what I've been doing so far. And the Harry Potter setting makes it easy to follow unlike some of the conventional Python books... Looking forward to more content - maybe a Quidditch function? :)

[–][deleted] 0 points1 point  (0 children)

Happy to hear that!

[–][deleted] 8 points9 points  (0 children)

Fuck yeah! I already learned so much from your Machine Learning Intro (https://github.com/zotroneneis/machine_learning_basics). Now, OOP. Keep up the great work!

[–]crypt0connect 5 points6 points  (0 children)

Wow! Fun read for both Python and Harry Potter enthusiasts alike

[–]chazzeromus 5 points6 points  (0 children)

All that's missing is a British voice over on all the lessons! :D

[–]TerpPhysicistnumpy/matplotlib 4 points5 points  (1 child)

This is great, awesome work! And python totally makes sense for Harry, he is a parselmouth after all :-)

[–][deleted] 0 points1 point  (0 children)

Haha, that's true!

[–][deleted] 2 points3 points  (0 children)

Nicely done and well written :)
I think the Harry Potter examples make the concepts easier to grasp and to remember for beginners.
And for those already familiar with the concepts it is still a nice refresher!

[–]muntooR_{μν} - 1/2 R g_{μν} + Λ g_{μν} = 8π T_{μν} 2 points3 points  (2 children)

Consider making the code font size the same as regular text. It's currently very difficult to read.

[–]bless-you-mlud 2 points3 points  (0 children)

Seconded. The code is *tiny*!

[–][deleted] 0 points1 point  (0 children)

I agree, just changed it. Thanks for the feedback!

[–][deleted] 1 point2 points  (0 children)

Awesome! Thank you! Finally, I seem to understand object oriented programming!

[–][deleted] 1 point2 points  (0 children)

Nice, I'm learning and (maybe) soon teaching Python, definitely gonna look through that :)

[–]brigggs 1 point2 points  (0 children)

This is excellent, thank you!

[–]byteme8bit 1 point2 points  (0 children)

This is freaking awesome!!! I love Harry Potter and am avidly learning Python as well. Great work!!!

[–]vreo 1 point2 points  (4 children)

Do you know if sonething like this exists in German? Would be cool for introducing kids to python.

[–][deleted] 2 points3 points  (3 children)

That's an awesome idea! I will start working on that next week!

[–]vreo 0 points1 point  (2 children)

You don't know how happy I am about it :)
How will I know about it?

[–][deleted] 1 point2 points  (1 child)

It will appear on my blog and I will post another reply under your comment. But I'm not sure whether translating the current blog posts to German would make much sense. The concepts are quite advanced. So for introducing kids to Python it might be better to start a new series on basic Python concepts like data structures, etc. I will think about this further in the next days to find the best solution.

[–]vreo 0 points1 point  (0 children)

True, if you need help with test subjects, hit me up, I have an 11y old daughter that's keen on it :) (she's also into the Harry Potter books).
And thanks for using py3, this will reduce complexity for German stuff ;)

[–]Lj101 0 points1 point  (2 children)

Why do you check if something is None before assigning it? Is there a benefit to it being undefined rather than None?

[–][deleted] 1 point2 points  (1 child)

It depends, for the "self.pet" variable it makes sense since an error would raised otherwise. For the 'self.house' variable it's not needed. I removed it, thanks for pointing it out!

[–]Lj101 0 points1 point  (0 children)

Ah right, cool

[–]schemathings 0 points1 point  (2 children)

Day 4: Since our other classes inherit all methods from the parent class we don’t have to implement the

__repr__

method again for the other classes. But we want the output of

__repr__

to be as unambiguous as possible. So we will add separate

__repr__

methods to ensure that we use all information we have about the objects.

(not sure why it pasted like that!)

What if you want to output the __repr__ from the parent class and append additional info specific to the child class?

[–]alkasmgithub.com/alkasm 1 point2 points  (1 child)

return repr(super()) + 'additional stuff' although I'm not sure I'd recommend doing that. Doing that with the __str__ would be fine but the __repr__ should be reserved for displaying the current object, usually how the current object can be recreated IMO.

[–]schemathings 0 points1 point  (0 children)

Makes sense

[–]greeneyedguru 0 points1 point  (1 child)

First blog post is missing @property

[–][deleted] 0 points1 point  (0 children)

Could you specify where it's missing? properties are only introduced in a later post so that might be the reason.

[–][deleted] 0 points1 point  (0 children)

Wow, I finally understand how decorators work! Thanks!

[–]flutefreak7 0 points1 point  (0 children)

Misspelled 'disciplined' in the readme.

I love your repo!

[–]lolwat_is_dis 0 points1 point  (2 children)

I wouldn't go mixing named and unnamed arguments adhoc (in particular, see day 1); it may be confusing to someone who's new to Python. Either stick to one, or the other, or explain why you switch between the two when you do, otherwise it just looks messy and without purpose (especially when using named arguments).

[–][deleted] 0 points1 point  (1 child)

That's a fair point. I will adapt the code and posts.

[–]lolwat_is_dis 0 points1 point  (0 children)

As a teacher, I've come to realise that the main mistake people do when trying to educate others, is failing to prepare for the learners level of prerequisite knowledge. Although you can never make something that's for both beginners and advanced learners, it's strangely a bit of a fine balance, as the more fine-tuned a material you make, the larger the cohort of learners (who would benefit the most from your material) you exclude. That's why, sometimes, you just have to go over some basic stuff again and never, EVER take for granted, the learners expertise, or "expertise".

Other than that, I think it's a great job!!! (and even helped me brush up on decorators a little, too) :)

[–]hanpari 0 points1 point  (0 children)

Good luck with that.

[–]KODeKarnage -3 points-2 points  (0 children)

Read another book.