Skip to content

python magic methods

Sunday, 29 December 2013

came across the use of the double underscore ( __ ) again while snooping through  the chapters of How to Think Like a Computer Scientist: Learning With Python” by Jeffrey Elkner, Allen B. Downey, and Chris Meyers but could not pinpoint what they meant. vague remembrance and association with classes and methods from my codecademy sessions but, other than that, zip, nada, blanco. called up goggleFu and voila — A Guide to Python’s Magic Methods by Rafe Kettler. in his own words:

” What are magic methods? They’re everything in object-oriented Python. They’re special methods that you can define to add “magic” to your classes. They’re always surrounded by double underscores (e.g. __init__ or __lt__). They’re also not as well documented as they need to be. All of the magic methods for Python appear in the same section in the Python docs, but they’re scattered about and only loosely organized. There’s hardly an example to be found in that section (and that may very well be by design, since they’re all detailed in the language reference, along with boring syntax descriptions, etc.).

“So, to fix what I perceived as a flaw in Python’s documentation, I set out to provide some more plain-English, example-driven documentation for Python’s magic methods. I started out with weekly blog posts, and now that I’ve finished with those, I’ve put together this guide.”

did i download the pdf version? of course i did! from here. thanks rafe!

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Fresh hacks every day

Don Charisma

because anything is possible with Charisma

The Grand Narrative

Korean Feminism, Sexuality, Popular Culture


This site is the bee's knees


helps you have more fun with knowledge creation

Ask a Korean!

rebooting a coding journey

Stupid Ugly Foreigner

Walk softly and carry a big stick. You'll need it to fight the monkeys.

Gusts Of Popular Feeling

rebooting a coding journey

I'm no Picasso

rebooting a coding journey

The Daily Post

The Art and Craft of Blogging

%d bloggers like this: