You are on page 1of 15

PYTHON

-By Arvind Rajpurohit

What is Python?

Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.

Often, programmers fall in love with Python because of the increased productivity it provides. Since there is no compilation step, the edit-test-debug cycle is incredibly fast. Debugging Python programs is easy: a bug or bad input will never cause a segmentation fault. Instead, when the interpreter discovers an error, it raises an exception. When the program doesn't catch the exception, the interpreter prints a stack trace. A source level debugger allows inspection of local and global variables, evaluation of arbitrary expressions, setting breakpoints, stepping through the code a line at a time, and so on. The debugger is written in Python itself, testifying to Python's introspective power. On the other hand, often the quickest way to debug a program is to add a few print statements to the source: the fast edit-test-debug cycle makes this simple approach very effective.

How To Install Python


Downloading and Installing Python
First we must download the proper installation package. You can download it from http://www.python.org/download/windows

Click on the circled link labeled individual releases. 1. You will be taken to a list of Python releases. Choose 2.5.1 which is the first one.Now you can get new version available on the same site

2. Most of you will download the installation package of windows-32 bit(x86). If you are using an Itanium or AMD-64 machine, you will need to use one of the other installation packages pictured below. If you are not sure, right click on My Computer and choose Properties.This also assumes that you have Windows XP. If you have an earlier version of windows, you will need to download Microsoft Installer. The link is next to the second balloon in the image below.

3. If you are using Firefox the following box will appear. Click Save File. You can monitor the download using the Download Manager by accessing the Tools menu and then selecting Downloads.

Once the download is complete, click on Open to start the installer.

If you are using Internet Explorer the following box will appear when you click on the link.

Click on Run.

I think we can trust this download, so click Run.

4. The Python installer should open. Select who you want to have access to Python: just yourself, or anyone on the system. If you are the only one that uses your computer, then it does not really matter which one you choose. Just choose one and click Next.

5. Next, choose a directory where Python should be installed. You should really just leave it as is and click Next.

6. Accept the default installation options in this screen and click Next

7. Python will begin installing on your system. In just a few minutes you will have the world's greatest language on your own computer!

8. The installer should complete, yielding the following screen. Click Finish.

Now what? Let's look at what was installed.

Using the Windows Python Installation


1. Click on the Start menu and find the Python 2.5.1 program group. We see that a few things have been installed.

IDLE (Python GUI) which is like the command line Python prompt on the servers except it has a graphical user interface (menus, buttons, etc.)

Module Docs which is a help file consisting of documentation on the installed Python modules.

Python (command line) which looks just like the prompt on the servers.

o o

Python Manuals for help when you need it. Uninstall Python which you will NEVER EVER use.

WHY PYTHON ??
1) Python is robust
There is a good reason why Bank of America has chosen Python to power many of their critical systems. (source) It's solid and powerful. Python has a relative small quantity of lines of code, which makes it less prone to issues, easier to debug, and more maintainable. The Securities Exchange Commission has sought to mandate Python as the language for a new "waterfall" program that would make Wall Street more transparent. Python can scale to solve complex problems, as illustrated by the fact that it powers most of YouTube and DropBox, not to mention Reddit, Quora, Disqus and FriendFeed. Even the mighty Google has made Python one of its official programming languages. It's also very fast.

2) Python is flexible

In 2007 YouTube migrated from PHP to Python for scalability purposes, citing that "Python enables flexibility". Python is used in a wide array of industries and for a long list of different usages, from websites and web applications to systems administration, voice over IP, and desktop apps. Python is also a staple of the Scientific community. Because it wasn't originally created to answer a specific need, Python isn't driven by templates or specific APIs, and is therefore well-suited to rapid development of all kinds of applications. As a company focused on advanced web development, we really like this flexibility.

3) Python is easy to learn and use

"Python in particular emerges as a near ideal candidate for a first programming language", says John M. Zelle, in the Department of Mathematics, Computer Science, and Physics at Wartburg College in Iowa (source). We certainly agree with this as we find Python intuitive and fun. We

don't have to look up references frequently, nor are we overwhelmed by the formalities of the language, like we would in Java or C++. Python's simple and straight-forward syntax also encourages good programming habits, especially through its focus on white space indentation, which contributes to the development of neat looking code. Finally, while PHP is notorious for the inconsistency in its naming methods, Python's naming convention is prevalent from module to module, so developers are less likely to make syntax errors. This means fewer bugs and faster development.

4) Python reduces time to market

Gartner estimates that 90% of enterprises are using open source softwareincluding Perl, Python and Tclto build business-critical applications. That's because dynamic languages are an excellent solution for fast time-to-market for enterprise applications. Python makes it possible to get applications to market faster in part due to the fact that it has a huge standard library and is often referred to as coming with "batteries included". In addition, Python stays out of my way. Therefore I can be more productive than if I was using Java/XML: the same task will require less code using Python.

5) Python is free.

Since Python is an open source programming language, we immediately reduce up-front project costs by leveraging Python in our development projects. Now, I'll agree that, more than a choice of language, what matters is the experience of the development team, their process, and how well they follows standards and best practices. We only work with experts in their fields so we can be proud of the code we deliver. Should you need assistance with your Python project, we'll be happy to help through a variety of professional services.

Comparing Python to Other Languages


Python is often compared to other interpreted languages such as Java, JavaScript, Perl, Tcl, or Smalltalk. Comparisons to C++, Common Lisp and Scheme can also be enlightening. In this section I will briefly compare Python to each of these languages. These comparisons concentrate on language issues only. In practice, the choice of a programming language is often dictated by other real-world constraints such as cost, availability, training, and prior investment, or even emotional attachment. Since these aspects are highly variable, it seems a waste of time to consider them much for this comparison.

Java
Python programs are generally expected to run slower than Java programs, but they also take much less time to develop. Python programs are typically 3-5 times shorter than equivalent Java programs. This difference can be attributed to Python's built-in high-level data types and its dynamic typing. For example, a Python programmer wastes no time declaring the types of arguments or variables, and Python's powerful polymorphic list and dictionary types, for which rich syntactic support is built straight into the language, find a use in almost every Python program. Because of the run-time typing, Python's run time must work harder than Java's. For example, when evaluating the expression a+b, it must first inspect the objects a and b to find out their type, which is not known at compile time. It then invokes the appropriate addition operation, which may be an overloaded user-defined method. Java, on the other hand, can perform an efficient integer or floating point addition, but requires variable declarations for a and b, and does not allow overloading of the + operator for instances of user-defined classes. For these reasons, Python is much better suited as a "glue" language, while Java is better characterized as a low-level implementation language. In fact, the two together make an excellent combination. Components can be developed in Java and combined to form applications in Python; Python can also be used to prototype components until their design can be "hardened" in a Java implementation. To support this type of development, a Python implementation written in Java is under development, which allows calling Python code from Java and vice versa. In this implementation, Python source code is translated to Java bytecode (with help from a run-time library to support Python's dynamic semantics).

Javascript
Python's "object-based" subset is roughly equivalent to JavaScript. Like JavaScript (and unlike Java), Python supports a programming style that uses simple functions and variables without engaging in class definitions. However, for JavaScript, that's all there is. Python, on the other hand, supports writing much larger programs and better code reuse through a true object-oriented programming style, where classes and inheritance play an important role.

Perl
Python and Perl come from a similar background (Unix scripting, which both have long outgrown), and sport many similar features, but have a different philosophy. Perl emphasizes support for common application-oriented tasks, e.g. by having built-in regular expressions, file scanning and report generating features. Python emphasizes support for common programming methodologies such as data structure design and object-oriented programming, and encourages programmers to write readable (and thus maintainable) code by providing an elegant but not overly cryptic notation. As a consequence, Python comes close to Perl but rarely beats it in its original application domain; however Python has an applicability well beyond Perl's niche.

Tcl
Like Python, Tcl is usable as an application extension language, as well as a stand-alone programming language. However, Tcl, which traditionally stores all data as strings, is weak on data structures, and executes typical code much slower than Python. Tcl also lacks features needed for writing large programs, such as modular namespaces. Thus, while a "typical" large application using Tcl usually contains Tcl extensions written in C or C++ that are specific to that application, an equivalent Python application can often be written in "pure Python". Of course, pure Python development is much quicker than having to write and debug a C or C++ component. It has been said that Tcl's one redeeming quality is the Tk toolkit. Python has adopted an interface to Tk as its standard GUI component library. Tcl 8.0 addresses the speed issuse by providing a bytecode compiler with limited data type support, and adds namespaces. However, it is still a much more cumbersome programming language.

Smalltalk
Perhaps the biggest difference between Python and Smalltalk is Python's more "mainstream" syntax, which gives it a leg up on programmer training. Like Smalltalk, Python has dynamic typing and binding, and everything in Python is an object. However, Python distinguishes built-in object types from user-defined classes, and currently doesn't allow inheritance from built-in types. Smalltalk's standard library of collection data types is more refined, while Python's library has more facilities for dealing with Internet and WWW realities such as email, HTML and FTP. Python has a different philosophy regarding the development environment and distribution of code. Where Smalltalk traditionally has a monolithic "system image" which comprises both the environment and the user's program, Python stores both standard modules and user modules in individual files which can easily be rearranged or distributed outside the system. One consequence is that there is more than one option for attaching a Graphical User Interface (GUI) to a Python program, since the GUI is not built into the system.

C++
Almost everything said for Java also applies for C++, just more so: where Python code is typically 3-5 times shorter than equivalent Java code, it is often 5-10 times shorter than equivalent C++ code! Anecdotal evidence suggests that one Python programmer can finish in two months what two C++ programmers can't complete in a year. Python shines as a glue language, used to combine components written in C++.

Common Lisp and Scheme


These languages are close to Python in their dynamic semantics, but so different in their approach to syntax that a comparison becomes almost a religious argument: is Lisp's lack of syntax an advantage or a disadvantage? It should be noted that Python has introspective capabilities similar to those of Lisp, and Python programs can construct and execute program fragments on the fly. Usually, real-world properties are decisive: Common Lisp is big (in every sense), and the Scheme world is fragmented between many incompatible versions, where Python has a single, free, compact implementation.

Python Features:
->

Python's feature highlights include:


Easy-to-learn: Python has relatively few keywords, simple structure, and a clearly defined syntax. This allows the student to pick up the language in a relatively short period of time. Easy-to-read: Python code is much more clearly defined and visible to the eyes. Easy-to-maintain: Python's success is that its source code is fairly easy-tomaintain. A broad standard library: One of Python's greatest strengths is the bulk of the library is very portable and cross-platform compatible on UNIX, Windows, and Macintosh. Interactive Mode: Support for an interactive mode in which you can enter results from a terminal right to the language, allowing interactive testing and debugging of snippets of code. Portable: Python can run on a wide variety of hardware platforms and has the same interface on all platforms. Extendable: You can add low-level modules to the Python interpreter. These modules enable programmers to add to or customize their tools to be more efficient. Databases: Python provides interfaces to all major commercial databases.

GUI Programming: Python supports GUI applications that can be created and ported to many system calls, libraries, and windows systems, such as Windows MFC, Macintosh, and the X Window system of Unix. Scalable: Python provides a better structure and support for large programs than shell scripting.

For better understanding about Python Language you can watch video at following link: http://www.youtube.com/watch?v=pWcEjHovZRQ&list=PLF71E274964C81377

For any queries you can contact me at: * twitter.com/Official_Arvind *


http://www.facebook.com/arvind.rajpurohit.92

You might also like