My latest experience in learning Python has centered around classes, which is a concept that is really at the heart of what makes Python an object-oriented programming language. It’s been challenging, and I’m just barely scratching the surface, but it has been a lot of fun so far. I can tell that this concept is core to defining whole categories of objects and the actions and behavior that your code will take towards those categories. Classes allow you to apply this logic towards objects more consistently, at least that’s the theory. Below is a super simple example I’ve taken from Eric Matthes’ Python Crash Course:

<script type="text/javascript">
function resizeIframe(ifrm) {   = ifrm.contentWindow.document.body.scrollHeight + 'px';
    // Setting the width here, or setting overflowX to "hidden" as above both 
    // work for this page. It may be that one turns out to be better. = ifrm.contentWindow.document.body.scrollWidth + 'px';

<script type="text/javascript">
function onLoad() {    
    var ifrm = document.getElementById('ipython_notebook_frame');   
    setTimeout(resizeIframe, 0, ifrm);

<iframe id="ipython_notebook_frame" style="height: 500px; width: 100%; padding: 0; border: none;" src="" width="300" height="150">

<script type="text/javascript">
// By deleting and reinstating the iframe src, and by using setTimeout
// rather than resizing directly we convince Safari to render the
// page. See
var iframe = document.getElementById('ipython_notebook_frame');
iframe.onload = onLoad;
var iSrc = iframe.src;
iframe.src = '';
iframe.src = iSrc;

What this example is showing is that we’re able to make an attempt at modeling a dog, creating the behavior and actions around any dog (it could be millions of dogs, but we only will need to do this once), and then proving this logic by applying various methods to different dogs.

Please follow and like us: