Home  |   Guest Book |    Technical Page |    Personal Page   

PYTHON from Basics to Advance
 
About Me
Who is a Good QA
Latest News
Testing Concepts
Automation Tools
Agile Development
UNIX Basics
Perl Scripting
Python Scripting
MySQL
Technology
Repository
Imp. Commands
My Resume
 

Python is a general purpose interpreted, interactive, object-oriented and high-level programming language. 
Python was created by Guido van Rossum

Python Overview: 
Python is a high-level, interpreted, interactive and object oriented-scripting language. 
 =>  Python is Interpreted 
 =>  Python is Interactive 
 =>  Python is Object-Oriented 
 =>  Python is Beginner's Language

Python's feature highlights include: 
 =>  Easy-to-learn 
 =>  Easy-to-read 
 =>  Easy-to-maintain 
 =>  A broad standard library 
 =>  Interactive Mode 
 =>  Portable 
 =>  Extendable 
 =>  Databases 
 =>  GUI Programming 
 =>  Scalable

Reserved Words:
The following list shows the reserved words in Python. These reserved words may not be used as constant or variable or any other identifier names.
Keywords contain lowercase letters only. 

and

exec

not

assert

finally

or

break

for

pass

class

from

print

continue

global

raise

def

if

return

del

import

try

elif

in

while

else

is

with

except

lambda

yield

Lines and Indentation:
Blocks of code are denoted by line indentation, which is rigidly enforced. The number of spaces in the indentation is variable, but all statements within the block must be indented the same amount. Both blocks in this example are fine:       

      if True: 
          print "True" 
      else: 
          print "False"

Multi-Line Statements:
Statements in Python typically end with a new line. Python does, however, allow the use of the line continuation character (\) to denote that the line should continue.

total = item_one + \
        item_two + \
        item_three

days = ['Monday', 'Tuesday', 'Wednesday',
            'Thursday', 'Friday']

Quotation in Python:
Python accepts single ('), double (") and triple (''' or """) quotes to denote string literals, as long as the same type of quote starts and ends the string.
The triple quotes can be used to span the string across multiple lines
        word = 'word' 
        sentence = "This is a sentence." 
        paragraph = """This is a paragraph. It is 
        made up of multiple lines and sentences."""

Comments in Python:
A hash sign (#) that is not inside a string literal begins a comment. All characters after the # and up to the physical line end are part of the comment, and the Python interpreter ignores them.
#!/usr/bin/python # First comment
print "Hello, Python!"; # second comment

Using Blank Lines:
A line containing only whitespace, possibly with a comment, is known as a blank line, and Python totally ignores it.
In an interactive interpreter session, you must enter an empty physical line to terminate a multiline statement.

Multiple Statements on a Single Line:
The semicolon ( ; ) allows multiple statements on the single line given that neither statement starts a new code block. Here is a sample snip using the semicolon:
        import sys; x = 'foo'; sys.stdout.write(x + '\n')

Multiple Statement Groups as Suites:
Groups of individual statements making up a single code block are called suites in Python.
Compound or complex statements, such as if, while, def, and class, are those which require a header line and a suite.
Header lines begin the statement (with the keyword) and terminate with a colon ( : ) and are followed by one or more lines which make up the suite.
        if expression : 
              suite 
        elif expression : 
              suite 
        else : 
              suite


 Python Programming is divided into following sections:

  1. Basic data types, Operators and expressions Control Flow (if/then/else, looping etc.) 
  2. Functions and modules Data structures File handling , Exception handling
  3. OOPS concepts in python
  4. IMPORTANT FUNCTIONS
.....

Copyright 2009 Kunal Saxena Inc. All rights reserved