Classes are objects"In Python, everything is an object"That applies for classes as well which means that classes:can be created at runtimepassed as paramtersreturned from funtionsassigned to variablesBuiltin type functionThe simplest way to create class dynamically is to use type :def create_klass(name, **kwattrs): return type(name, (object,), dict(**kwattrs))>> my_test_klass = create_klass('MyTestClass',
Monday, December 21, 2015
Tuesday, December 15, 2015
Python : filter(), map() and reduce()
filter(), map() and reduce() tools are functional programming methods that can beapplied to iterable objects.filter(<function>, <object>)Iterates on object and returns the list of elements from <object> for which <function> returned True.Usually, lambda functions are used for <function>. A lambda function returns True when the condition is met (example :
Monday, November 30, 2015
Three-tier application architecture
The three tier architecture is a client-server software architecture pattern which consists of 3 layers :Presentation layer (or tier)Application's topmost level, also called graphical user interface or GUI.It displays the services to the user as well as the results of operations.Example of technologies used for this tier : WPF,
Thursday, November 26, 2015
C++ : Private pure virtual method
class Engine{public: void SetState( int var, bool val ); { SetStateBool( int var, bool val ); } void SetState( int var, int val ); { SetStateInt( int var, int val ); }private: virtual void SetStateBool(int var, bool val ) = 0; virtual void SetStateInt(int var, int val )
C++ : Inheritance types
class A {public: int x;protected: int y;private: int z;};class B : public A{ // x is public // y is protected // z is not accessible from B};class C : protected A{ // x is protected // y is protected // z is not accessible from C};class D :
Thursday, November 12, 2015
C++ : copy constructor
We already know the basic constructor utility which is : initializing internal members. If not constructor is specified, the default constructor initializes each of class' members with their constructor.Now let's take a look to the copy constructor :Point (const Point & p);This constructor will initialize our object by copying
Monday, November 9, 2015
c++ : lvalue and rvalue
l-valueC-definition An object is a manipulatable region of storage; an lvalue is an expression referring to an object....The name 'lvalue' comes from the assignment expression E1 = E2 in which the left operand E1 must be an lvalue expression. C Programming Language (Prentice-Hall, 1988)r-valueC-definitionWhat is sometimes called 'rvalue' is in
Sunday, April 12, 2015
Mount external hard drive with write permissions
This post has been created to keep a track of this very usual issue that I encountered recently. There are many discussions around it already but I thought that adding a very simple article with a few explanations couldn't harm. So here it is. Linux permissions do not apply
Subscribe to:
Posts (Atom)