python programming language


LANGUAGE EVOLUATION: In 1991 python released by Guido van Rossum as open language and followed community based development model and evolution is managed by non-profit Python Software Foundation. Most Parts of the language is formally specified and some parts are goes as de-facto standards. Python was initially released 1991 as version 0.9.0 and was a module system. This initial release consist class with inheritance, exception handling, functions. With start of comp.lang.python user group at 1994 user base for the language started to grow.

Python reached version 1.0 in January 1994. The major new features included in this release were the functional programming tools lambda, map, and filter and reduce.

Python 1.4 had introduced major changers to the programming language. The basic features included were keyword arguments, built in support for complex numbers, and basic form of data hiding by data mangling

(Name mangling is a technique used to resolve the problem of needing unique names for resolving programming entities).

In year 2000 Python version 1.6 and 2.0 was released and those versions are consequently overlapped. Version 2.0 contains major features from SET language, Haskell And as another major feature Garbage collection based on the reference cycles.

Python is language which is rapidly changed evaluated through deferent versions. It’s also planned its feature. A Python Enhancement Proposal (or "PEP") is a standardized design document providing general information related to Python, including proposals, descriptions, and explanations for language features. PEPs are intended as the primary channel for proposing new features, and for documenting the underlying design rationale for all major elements of Python. There are plans for a future version, to be called Python 3.0 (the project is called "Python 3000" or "Py3K") that will break backwards compatibility with the 2.x series in order to repair perceived flaws in the language.

Python 3.0 is being developed with the same philosophy as in prior versions, so any reference to Python philosophy will apply to Python 3.0 as well. However, as Python has accumulated new and redundant ways to program the same task, Python 3.0 has an emphasis on removing duplicative constructs and modules, in keeping with "There should be one—and preferably only one—obvious way to do it".

Nonetheless, Python 3.0 will remain a multi-paradigm language. Coders will still have options among object orientation, structured programming, functional programming, and aspect-oriented programming and other paradigms, but within such broad choices, the details are intended to be more obvious in Python 3.0 than they have become in Python 2.x.

Some of the major changes scheduled for Python 3.0 are:

  • Changing print so that it is a built-in function, not a statement. This makes it easier to change a module to use a different print function, as well as making the syntax more regular. In Python 2.6 this can be enabled by entering from __future__ import print_function
  • Moving reduce (but not map or filter) out of the built-in namespace and into functools (the rationale being that reduce is expressed more clearly as an accumulation loop);
  • Adding support for optional function annotations that can be used for informal type declarations or other purposes
  • Unifying the str/unicode types, representing text, and introducing a separate immutable bytes type; and a mostly corresponding mutable buffer type, which both represent arrays of bytes
  • Removing backward-compatibility features, including old-style classes, integer-truncating division, string exceptions, and implicit relative imports.

OBJECTIVE OF THE LANGUAGE:  To develop an interpreted, Object oriented, Portable, Extensible, Embeddable language was python’s main objectives, and language with improved readability.  From one perspective you can say Python is a very high-level scripting language. From another perspective you can say it's a high-level programming language that happens to be implemented in a way that emphasizes interactivity. Python shares some characteristics with scripting languages, but also shares some characteristics with more traditional programming languages

APPLICAION DOMAIN TARGETED: Pythons application domain is not narrowed down to the particular domain but it can be easily use to provide software solution for vast industry problems, for example Web and internet Development. In web based development it provides wide range of choices like CGI scripts, Frame works such as Django and Turbo Gears High end solution such as Zope, content Management Systems like Plone. For custom web solution and other internet applications python provides extensive support for HTML, XML, E-mail processing, RSS feeds many more internet protocols. And python provides customized Database interfaces for MySQL, Oracle, MS SQL Server, Postgre SQL, SybODBC bundled with standard database API. Its support Object databases like ZODB and Durus. And python supports GUI development, Scientific and numeric computing. Also python is a good programming language to start learns a programming language. It also has extensive support Networking and graphics development.

 

IMPLIMENTATION MODEL:  Python uses a compiler and interpreter to compile and run programs. Python compiler/parser produces byte code acceding to the source code written. Then virtual machine interprets the byte code same as java but compiling to byte code is implicit.

There are other python implementations also, for an example Jython compiles python code to java byte code, IronPython compiles python code to DOT NET.

 

 

 

 

 

 

TYPE OF META-LANGUAGERS USED: Python basically used python it self as a Meta language and C as another Meta language. So in python there can be seen to different types of modules one is written by python language it self and others written in C.

 

STRUCTURE OF PROGRAMS:  Python has two basic modes the normal “mode” is the mode where scripted and finished .py are run in the python interpreter. Interactive mode is a command line shell which gives immediate feed back after each statement, while running previously fed statements in active memory. As new lines are fed into the interpreter the fed program is evaluated both in part and in whole. Python programs are text files and can be coded using a standard text editor. Python programs are composed of modules and modules contain statements, and they contain expressions. Expressions create and process modules.

At its core, Python syntax is composed of statements and expressions. Expressions process objects and are embedded in statements. Statements code the larger logic of a program's operation—they use and direct expressions to process the objects we studied in the preceding chapters. Moreover, statements are where objects spring into existence (e.g., in expressions within assignment statements), and some statements create entirely new kinds of objects (functions, classes, and so on). Statements always exist in modules, which themselves are managed with statements.

 

 

SPECIAL FEATURES INTRODUSED BY THE LANGUAGE: used indentation for statement grouping instead of curly braces or begin-end blocks, and developed a small number of powerful data types and interactive interpreter.

 

SYNTATIC STRUCTURE OF COMMENTS: There are two styles of comments in python. Single line comments and multi line comments.

#  this is single line comment

 

" " " this is a multiline comment
  which spawns many lines
" " "
Multi line comments are also used to embed what are called doc strings in a function. If u has a class says 
of type schoolText Box: class school:    """ this class is useful for defining a type of school  with its strength,affiliation,address etc this class has following methods and properties   affilitaion()   address() """ def affiliation(board): def address(add): in this piece of code the triple qouted string not only is  a comment but when i declare an object say
t=school
 
and then t . __doc__  returns those comments
 
also help(school)  returns same comments
 
 

SYNTATIC STRUCTURE OF OBJECT NAMES: Python's objects are basically a bunch of attributes. These attributes include the type of the object, fields, methods, and base classes. Attributes are also objects, accessible through their containing objects. All Python objects have a unique identity (an integer, returned by id(x)), a type (returned by type(x)), and some content. Object really name not really property of the object, Object it self doesn’t know what it is called. Object can have many names or no one at all. Names live in namespaces (such as a module namespace, an instance namespace, a function’s local namespace). Namespaces are collections of (name, object reference) pairs (implemented using dictionaries). When you call a function or a method, its namespace is initialized with the arguments you call it with (the names are taken from the function’s argument list, the objects are those you pass in). Assignment statements modify namespaces, not objects. name = 10 means that you’re adding the name “name” to your local namespace, and making it refer to an integer object containing the value 10. If the name is already present, the assignment replaces the original name.

name=10
name=20
means that you’re first adding the name “name” to the local namespace, and making it refer to an integer object containing the value 10. You’re then replacing the name, making it point to an integer object containing the value 20. The original “10” object isn’t affected by this operation, and it doesn’t care.

 

SCOPE AND LIFE-TIME OF VARIABLES: Global variables are accessible inside and outside of functions. Local variables are only accessible inside the function. In the example below, the function can access both the global and the local variable. However, trying to access the local variable outside the function produces an error.






global_var = 'foo'
def ex1():
    local_var = 'bar'
    print global_var
    print local_var
 
ex1()
print global_var
print local_var 

 

 

foo
bar
foo
Traceback (most recent call last):
    line 9, in 
    print local_var  # this gives an error
NameError: name 'local_var' is not defined

 

 
 

 

 

 

 

 

 

 

 

 


If we set a variable in a function with the same name as a global variable, we are actually creating a new local variable. To set the global variable inside a function, need to use the global statement. This declares the inner variable to have module scope. Bellow example var remains 'bar' after the function is called.






var = 'foo'
def ex3():
    global var
    var = 'bar'
    print 'inside the function var is ', var
 
ex3()
print 'outside the function var is ', var

 

 

inside the function var is  bar
outside the function var is  bar

 

 
 

 

 

 

 

 

 


Text Box: def ex4():     var_outer = 'foo'     def inner():         var_inner = 'bar'         print var_outer         print var_inner     inner()     print var_outer     print var_inner # this gives an error  ex4()Scoping for nested functions works similarly. In this example, the inner function can access both var_outer and var_inner. However, the outer function cannot access var_inner.

 

 

 

 

 

 

 

During everyday programming it is not necessary to explicitly remove variables from the work space. All local variables of a function die on exit from that function anyhow, and the variables in the global name space usually do not need special treatment. However, there are conditions under which it is preferable to wipe out a variable completely. This happens if you need to avoid a pollution of the name space while working with the list of all variables, e.g. who ('local'). The correct command to kill variable v is - clear v

CONTROL STRUCTIRES: If, while, For, Try are main control structures of the python language. If statement checks condition that is either true or false before the intended block to be executed. “elif”, “else” are other control structures that combined with if structure. And for the Boolean operations “and”, “or”, “not” operators can be used. 

 

Text Box: if (boolean and otherboolean) or ( not boolean ):       x = 1 elif not otherboolean:     x = 0 else:     x = 100000000000000000000

While loop executes following code block until given condition is false. “For loops” are actually very interesting because they don't behave just like C for loops, although they can. For loops in Python iterate over Lists instead of just incrementing integers.

 

(Sample if structure)

# Basic For Loop
for item in list:
    dosomething(item)
for x in range(0, 100):
    dosomething(x)

 

 
while condition == true:
    """do the following"""
    ...
    ...
    condition = false.

 

 
Python has “pass”, “continue”, “break” control statements. Try and except handlers used in exceptions.

 

 

 

 

 

 

 

 

 

Comments