Saturday, February 11, 2012

Prototypes and 'new' statement in Javascript

The blog is now moved here

The purpose of this article is to be a reminder how prototypes in javascript works. It is not full manual or detailed guide how to deal with that. So let's get started.

Classes in javascript is simply functions. Let's create few
var A = function(){
    this.some = 'A value';
    this.another = 'A value another';
}
Now we have two functions which can be be instantiated with new keyword
var a = new A();

Wednesday, January 18, 2012

Python dictionary with default values

The blog is now moved here

Recently, I had a task to call method with certain parameters passed to another function inside it. 

The code looks like this:

class SomeClass(object):    
    def some_method(self, arg2, params, kwarg1='default_value', 
                                        kwarg2='default_value'):        
        return external_module.meth(**params)