Everything you wanted to know about Python Language



1. What is Python programming language?
Python is a dynamically-typed, strongly-typed, interpreted, open source programming language. Python runs on Windows, Linux/Unix, Mac OS X, and has been ported to the Java and .NET virtual machines. Python is free to use, even for commercial products, because of its OSI-approved open source license.


2.How can I learn to program in Python?

By James Thornton

The easiest way to learn a programming language is to first learn the basics and then try to build something with it (learn by doing). And it’s better if you are building something you are actually interested in rather than something out of a book because it will get you to think about the problem and be more meaningful.

Python is easy to learn (not much syntax), easy to read (explicit vs implicit), has a big ecosystem (more packages/libraries), is taught at universities so it’s easy to find good programmers to help, and is used by many large websites/companies (e.g., Quora is programmed in Python) so it’s a good language to know.

Online Python Tutorials (in order from introductory to more advanced):

  1. “A Byte of Python” http://www.swaroopch.com/notes/P…
  2. Google’s Into to Python Class (online) – http://code.google.com/edu/langu…
  3. “Dive Into Python”, by Mark Pilgrim http://diveintopython.org/toc/in…
  4. “The New Boston” Programming Python Tutorials – http://www.youtube.com/user/then…
  5. “Building Skills in Python”, by Steven F. Lott – http://homepage.mac.com/s_lott/b…
  6. “Think Python: How to Think Like a Computer Scientist” – http://www.greenteapress.com/thi…
  7. “Code Like a Pythonista: Idiomatic Python”  –http://python.net/~goodger/proje…
  8. OpenCourseWare: MIT 6.00 Introduction to Computer Science and Programming – http://ocw.mit.edu/courses/elect….
  9. MIT 6.01 Course Readings (PDF) – http://mit.edu/6.01/mercurial/sp…
  10. Google’s “Understanding Python” (more advanced talk) –
  11. “A Guide to Python’s Magic Methods” – http://www.rafekettler.com/magic…
  12. “Metaclasses Demystified” –http://cleverdevil.org/computing…

13. Book to Get: “Python Cookbook”, by Alex Martelli (http://www.amazon.com/Python-Coo…)

14. And if you’re building something Web based, look at using the Flask Web Framework (http://flask.pocoo.org/docs/).

Flask is a modern, lightweight, and well-documented Python Web framework so you won’t have to spend much time learning it or fighting with it — you won’t find yourself asking, “Will I be able to do what I want in the framework without hacking it?” Flask let’s you program in Python rather than writing to the framework like you typically have to in larger, opinionated framework’s like Django and Rails.


3.What tools should a modern Python developer have under his belt?
By Dhananjay Nene

Most important : Understand core python well. Many get taken in by the django promise of getting websites up and running quickly. Nothing wrong about the django promise – but it lacks the feedback loop of people realising that their understanding of core python isn’t what it could’ve been.

The toolbelt is not universal : Python gets used in a diverse set of scenarios. From web applications (django, pylons or now pyramid, tornado), to scientific and numerical computing (scipy, numpy or interfaces to R), networking (twisted or just core python), or system administration / monitoring / management automation. The full range of python libraries and toolkits is just too large to cover. The base toolbelt has to be fashioned based on the nature of applications you are currently and in near future likely to be working on. Others should be learnt on demand

There are some basic toolkits you must know irrespective of the domain : These are virtualenv, pip/easy_install, fabric, and your preferred unit testing framework.

For a “software engineer working mostly on distributed systems and web applications”, at least one of django / pyramid / tornado / bottle / web.py / turbogears is mandatory (which one is beyond the scope of this question). If your favourite web framework does not have database libraries, competence using tools such as SQLAlchemy or even basic python db-api would be useful. If using unconventional databases, you will need a good understanding of its libraries. A good understanding of urllib / urllib2 / httplib (all core python) will be necessary. In addition knowledge of twisted is likely to be helpful.

Finally, repeating to emphasise, understand core python well.


4.Which Internet companies use Python?
Primarily uses Python for development:

  • Apture
  • ChoiceVendor (company)
  • Digg
  • Disqus
  • Dropbox
  • Eventbrite
  • FriendFeed
  • Hunch
  • 6waves Lolapps
  • Lanyrd
  • Mixpanel
  • Mochi Media
  • Mozilla
  • Quora
  • Path
  • Pinterest
  • Raptr
  • reddit
  • Slide (company)
  • SlideShare
  • SurveyMonkey
  • uberVU
  • Venmo
  • Votizen
  • Yelp
  • YouTube
  • drchrono

Uses Python extensively as a supplemental language:

  • Asana
  • Google
  • Justin.tv
  • Second Life


5.What is the best Python web app framework?
By Charlie Cheever

The two that stand out to me are Django and Pylons.

Pylons makes more sense if you want to invest a lot in doing custom work on your framework; Django might be a better choice if you want to make a site like a newspaper (or other traditional CMS product.)

cherrypy can be a good choice for very small projects.

They both have lots of documentation and lots of users and are easy to setup.

I put some time into researching this in the spring of 2009.  We chose Pylons because the different parts are easy to swap out.  For example, we didn’t want to use a templating system, and it was easy to choose any templating system or just not use one with Pylons.  My impression was that it was slightly harder to do this in Django which has a tighter full stack integration.

If you want to use your web app framework as a CMS, Django is probably a better choice.  There are lots of convenient plug-ins and all the different pieces are setup to work up with each other so it’s easy to build things that are similar to a newspaper really quickly with it, and it has lots of administration and account things built-in in a way that Pylons doesn’t.

Ben Bangert, the creator of Pylons, has a somewhat informative discussion of Django vs. Pylons here.  http://stackoverflow.com/questio…

For small projects, I’ve used cherrypy sometimes, which isn’t perfect but runs as a standalone webserver and requires very little boilerplate to setup.  Flask is a new framework that is gaining popularity and seems to fill the same niche but be a little bit more refined than cherrypy. ( http://flask.pocoo.org/ )
 6. Why is Python better than PHP?

By Owen Yamauchi

Where to begin. There’s just so many reasons!

Mostly-legitimate (though sometimes a matter of preference) technical reasons

  • Python has a real module system.
  • Python distinguishes indexed arrays from associative arrays.
  • Python is stricter about dumb error conditions; e.g. undefined variables.
  • Python’s philosophy is more general-purpose than PHP’s originally was and thus it does not have weird artifacts like magic global variables $_GET and $_POST.
  • Python has functional-like features that are distinctive among mostly-imperative scripting languages, like list comprehensions. PHP has no such things.
  • Python has fewer easily abusable ways to write shitty code like
  • Python does not exhibit as many head-scratchingly strange behavioral oddities as PHP, for example the fact that in PHP, you cannot use the array-index operator on a function call expression.
  • Python generally has a nicer standard library.
  • Python ships with a REPL, which includes an interactive documentation viewer. Facebook had to write their own for PHP.
  • Python has passable Unicode support. PHP (5.2 anyway) is no better than C in this regard.

Cultural reasons

  • Python was not developed by a man who has publicly stated that he does not enjoy programming, and who clearly does not understand how to properly design a programming language.
  • Python does not suffer from the “hobbyist” problem to the same extent that PHP does. This is the problem wherein someone with no real training in programming works through a PHP tutorial on the Internet (many of which were written by hobbyists who do not really understand programming) and then thinks they understand programming.
  • On the flip side of this, Python is generally more popular in the open-source community, so there are more cool open-source Python projects than PHP.

Although Python is generally my fallback language of choice (i.e. it’s what I use if there’s no clearly better alternative), it would be disingenuous to give this answer without noting that Python has plenty of weaknesses of its own.
7.What are the main weaknesses of Python as a programming language?
By Aston Motes

Python’s name scoping/lookup seems like it works, but it actually breaks in some weird cases, due to the fact that the interpreter knows too much about local variables. Take for example this benign looking code:

c = "something"
def outer():
    def inner():
        print c

Unsurprisingly, running outer() prints “something”. But make one small tweak, setting a value for c within outer after the call of inner(), and all hell breaks loose:

c = "something"
def outer():
    def inner():
        print c
    c = "something else"
 >>> outer()
Traceback (most recent call last):
  File "<pyshell#10>", line 1, in <module>
  File "C:/Python25/test.py", line 6, in outer
  File "C:/Python25/test.py", line 5, in inner
    print c
NameError: free variable 'c' referenced before assignment in enclosing scope

What’s going on here? The python interpreter knows that you eventually assign to c within the scope of outer, then it assumes you want that same binding within inner (‘local’ is ‘local’) rather than just walking up the existing scopes to find the module-level c that worked in the first example. Python 3 fixes this behavior with the nonlocal keyword, but I mean, very weird behavior to have in the first place.


By Owen Yamauchi

Scoping rules (and the general fact that variable declaration and assignment are syntactically identical) are 90% of what I think is wrong with Python.

Other little annoyances:

  • Naming schemes in the standard library are inconsistent. For example, methods on the built-in string class are all-lowercase with no word separators (e.g. startswith), while methods in the standard library string module are all-lowercase with underscores (e.g. string.Formatter.get_field).
  • Lambda bodies can only be single expressions.
  • No ++ and — operators.
  • Object-oriented programming feels like an afterthought. You can’t declare instance variables. You can’t have private instance variables or methods — certainly not without some bizarre convolutions. Class methods are tacked on with this weird, hacky-seeming builtin function and a weird, hacky-seeming syntactic appendage (function decorators). (Unlike some, I don’t consider the explicit passing of self to instance methods to be a problem.)


Video Tutorials: Here


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.