4 ms·
It uses classes, magic methods where appropriate, is well documented, does its loops in a pythonic way; lots of things! It's taking advantage of idiomatic pytho
by AnkhMorporkian 11y ago
It uses classes, magic methods where appropriate, is well documented, does its loops in a pythonic way; lots of things! It's taking advantage of idiomatic python, as opposed to simply using python as a C-style hammer.
- wlesieutre 11y agoI wasn't familiar with the "magic methods" term, so for anyone else in the same boat, that refers to the functions like __init__, __repr__, __add__, __hex__, __len__, etc that you can define in your classes to make them work with built in functions like len(custom_listy_thing) or arithmetic.
- orf 11y agoMore than just built in functions, any object that defines a __len__ and a __index__ method (that provide len(x) and x[0] respectively) can also be iterated over in a for loop ('for item in instance'). A good reference for magic methods is [1] for anyone interested. 1. http://www.rafekettler.com/magicmethods.html http://www.rafekettler.com/magicmethods.html