Showing posts from October, 2017

A better example of Class Inheritance in Python

Lots of people ask me, why should they use classes at all ? Well. I think its about control, and ease . It solves the headache of data sharing and accessibility. I am going to show you an example , which hopefully proves that classes and fundamentals like inheritance  are brilliant.


I have  two classes in the below program. Person and Manager . Manager has inherited the Person class (because he is a person too....almost (lol)) .

class Person: def __init__(self, name, job, pay=0): = name self.job = job = pay def lastName(self): return[-1] def giveRaise(self, percent): = int( * (1 + float(percent)/100)) def __str__(self): return'[Person: %s, %s]' % (, class Manager(Person): def giveRaise(self, percent): = int( * (1 + ((float(percent)+10)/100)))
The only diff between a Manager is , he gets an extra 10% h…

How to run a Python program over the internet?

What am I trying to solve? I want to run a python program whenever I need and get some information out of it. The problem is, I want to call that through internet. And I want to show the content on a web page or some UI container. That's it. Let put this as a requirement.Problem: Display some information on my web page calculated by a python program. 
How do we do it on our local computer? We run our program as : python .So may be I can do something like: . Can we? No idea.

I expect to collect the response in some variable (no idea how can I create a variable in the first place on html) and then display the contents of this variable . Displaying a simple text on html is known , so that should be easy.

The program You must remember that we want some information from our program . It's a basic GET call where you just ask for some information from a server. You may or may not pass some inputs while doing this.