How to run Python scripts in your shared hosting server

Direct to the how-to 🙂

  1. First make sure your hosting supports Python. Now a days almost all shared hosting providers support Python.
  2. Find your python installation location, this is required for “shebang” line added at the top of your python script. Usually this is /usr/bin/python or /usr/local/bin/python
  3. Make sure to include two print statements which will print the content-type and an empty line.
  4. Now put the script in cgi-bin directory inside your root public folder, usually public_html
  5. Change the permission of the script to 0755
  6. Try to browse now 🙂

What is the difference between the variables of Python and other language

If you are from C/C++/Java and started learning Python, this should be an interesting topic for you.

In languages like C, C++, Java, PHP etc a variable is a memory location where its value is saved. When you copy a variable into another variable, both of them still in existence and you can use both of them.

But in Python, its different. As a matter of fact Python don’t have any variables, it has ‘name’ or ‘identifier’ attached to an object (everything in Python is an object).

Let me clear this using an example: