Become Pythonist



Contributors




Sohil Patel 
@sohil4932

Hitul Mistry 
@hitul007

Programming


Purpose ?


  • Make - Create App
  • Break - Edit App
  • Understand - How and why does it work ?

History










Over six years ago, in December 1989, I was looking for a "hobby" programming project that would keep me occupied during the week around Christmas. My office ... would be closed, but I had a home computer, and not much else on my hands. I decided to write an interpreter for the new scripting language I had been thinking about lately: a descendant of ABC that would appeal to Unix/C hackers. I chose Python as a working title for the project, being in a slightly irreverent mood (and a big fan of Monty Python's Flying Circus).
  • Salute this guy : Guino Van Rossum
  • Python conceived in late 1980s
  • Implementation was started in Dec 1989

WHAT IS PYTHON?

(The Zen of Python)
  • A dynamic, interpreted, high-level language
  • Does not require declaring the types of variables or parameters or methods
  • Extremely readable
  • Used for solving a really wide range of problems
  • Object-oriented
  • Does not force Object-orientation
  • Has and requires common sense

Who all are using Python?

 

and the list goes on...

Success Stories 

  • Nasa 
    • Since 1994
    • Maintenance
    • For any programmer, picking up Python is a one-week deal
  • Industrial Light & Magic 
    • Forrest Gump, Jurassic Park, Who Framed Roger Rabbit, Raiders of the Lost Ark, and Terminator 2
  • CISCO
    • DHCP in pure Python for Big ISP in Korea
    • 2 Million subscribers
  • Frequentis - Leading in Ait-Traffic control 
    • PanMachine in Lua
  • D-Link Australia uses python for Firmware updates 
  • Philips


Why Python ?


  • Make - Simple to get Started
  • Break - Easy to read and edit code
  • Understand - Modular and abstracted



Why Python?

  • Used by many companies across the world including Google, Rackspace, Industrial Light and Magic, Flickr and many others.
  • A thriving community of developers and contributors and third party application developers.
  • PyPI (Python Package Index) lists about 33500 third-party software projects*... You name an area, there must be a Python package in it and mostly opensource and free!
  • Interpreted, dynamically typed, clean syntax, very easy to learn.
  • Learn Python in Morning ;) - http://docs.python.org/2/tutorial/




Where ?


Show me the Money ?


  • IT salaries are up
  • Python is top growing skills last year
  • Average starting python programmer salary 440K INR

How to start ?


Hello, world

How it's done with Java and C++


public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World");
    }
} 

#include 
main()
{
    cout << "Hello World!";
    return 0;
} 
 
Requires a LOT more than just common sense.

The Pythonic way

Common sense: When you want to print a string, just print it.

In Python interpreter
 >>> print "Hello, world."

As a script
Open your favorite editor and type
#! /usr/bin/env python
print "Hello, world."
and save it as hello.py. And then execute it from command line as below
$ python hello.py

Python is fun

Let's try to swap 2 numbers
# The usual way>>> a = 10>>> b = 20>>> c = b>>> b = a>>> a = c>>> print a, b20 10
# The Pythonic way>>> a, b = 10, 20>>> a, b = b, a>>> print a, b20 10

Fun exercise

Let's find all Pycon US 2013 videos' download links :)

Are you ready for the challenge?

Solution


from BeautifulSoup import BeautifulSoup 
import requests 
 
url = 'http://pyvideo.org/category/33/pycon-us-2013/files' 
req = requests.get(url) 
data = req.text 
soup = BeautifulSoup(data) 
 
for link in soup.findAll('a', href=True): 
    # if link['href'].startswith(
	#'http://s3.us.archive.org/nextdayvideo/psf/pycon2013/'):
    if link.get('href', '').startswith(
            'http://s3.us.archive.org/nextdayvideo/psf/pycon2013/'): 
        #print link.get('href') 
        print link.get('href').split('?Signature')[0]

Python fun

Birthday wish python script 
--> in 40 lines of code

Check my university result 
--> In just 32 lines of code 

Friend result scrap by enrollment number
--> In just 20 lines of code

Ti zen application 
--> In just 300 lines of code 

Railway site check tickets booked
--> In just 70 lines of code 

Python Fun

Flipkart price change monitor 
--> In just 55 lines of code

Friend want galaxy S near x amount 
--> Wrote it in just 50 lines of code. 

Product reviews
--> Wrote in just 150 lines of code 

Get photos of my friends 
--> Wrote it in just 80 lines of code 

Merged bloggers
--> Wrote in just 70 lines of code 

Python Fun

Script to transfer file from pc to mobile 
--> In just 1 line 
python -m SimpleHTTPServer 8000

Python file downloader 
--> In just 5 line of code 

Cricket live score
--> In just 6 lines of code 

Flipkart check if my product came or not 
--> In just 50 lines of code 

Wanted 50-60 images to test gallery 
--> In just 7 lines of code. 

Links you can use

  • http://pypi.python.org - Python Package Index
  • http://docs.python.org/2/tutorial/ - The “official” Python tutorial
  • http://wiki.python.org/moin/MostPopularPythonProjects - 
  • http://www.python.org/community/workshops/ - Python 
  • http://wiki.python.org/moin/ - The Python “MoinMoin” Wiki
  • http://docs.python.org/devguide/ - All about developing Python
  • http://mail.python.org/mailman/listinfo - A list of all Python
  • http://pymbook.readthedocs.org/en/latest/ - Python for you & me
  • http://pythonbooks.revolunet.com/
  • http://www.codeacademy.com

Become Pythonist

By Patel Sohil

Become Pythonist

  • 550