Python (programming language)
Python is an easy and simple to use general purpose computer programming language. The language was originally developed by Guido van Rossum and continues to be developed by the Python community. The language is used in web programming, numeric and scientific computing, teaching programming and software development. The language has been widely adopted due to its modular implementation that enables development of new libraries to add functionality not found in the base language.[1]
Python is a high level programming language intended to be relatively straightforward for humans to read and process.Python is an interpreted programming language which use interpreter to be translated to machine language (zeros and ones) which machine understand.An interpreter reads the source code of the program as written by the programmer, parses the source code, and interprets the instructions On-The-Fly. When we are running Python interactively, we can type a line of Python (a statement) and Python processes it immediately and is ready for us to type another line of Python.
Python supports multiple programming paradigms such as interpreted, interactive and object-oriented programming. The language provides dynamic typing, very high-level dynamic data types, modules, exceptions, and classes. Python support a dynamic type system and automatic memory management and has a large and comprehensive standard library, open source. Python code can be executed in the various systems, and is extensible in C or C++. It is also usable as an extension language for applications that need programming interfaces. [2]
Python's name is derived from the T.V series Monty Python's Flying Circus and it's common to use Monty Python references in example code.The prefix Py is used to show that something is related to Python.
Contents
- 1 History
- 2 Rank
- 3 philosophy
- 4 conversing with Python
- 5 strengths
- 6 Weaknesses
- 7 The future of Python
- 8 Criticism
- 9 Python reserved words [5]
- 10 Syntax and semantics[6]
- 11 "Hello World" Example
- 12 Advanced Examples
- 13 Python Libraries [7]
- 14 Development Environment
- 15 Implementation
- 16 Python Enhancement Proposal[53]
- 17 Best Practices
- 18 Languages influenced by Python
- 19 Feature comparison of Python and other data science tools [62]
- 20 Average Programmer Salaries
- 21 Top Companies Providing Python Programming Services
- 22 Top 5 Recent Tweets
- 23 Top 5 Lifetime Tweets
- 24 References
History
- 1989: Implementation of Python started in December of 1989 by Guido van Rossum while working at CWI in the Netherlands.
- 1991: Van Rossum released the code (labeled version 0.9.0) to alt.sources In February 1991. [3]
- 2000: Python 2.0 was released with an emphasis on openness and community participation to reduce reliance on Guido's contribution. Python 2.0 had many new features, including a cycle-detecting garbage collector and support for Unicode.
- 2008: Python 3.0 was released without compatibility with earlier versions.
Rank
Since 2003, Python has ranked in the top ten most popular programming language as measured by the TIOBE programming community index. In September 2015, Python came in the fifth position of most popular programming language. In 2007 and 2010, It was ranked as the programming language of the year. It's the third most popular language whose grammatical syntax is not based on C, e.g. C++, objective-C.
philosophy
The philosophy of Python is summarized in a module called Zen of Python that is a collection of 19 software principles that inspires the design of Python programming language
Zen of Python is written as an informational entry number 20 in Python Enhancement Proposals (PEP), and can be found on the official Python website.It is also included as an easter egg in Python interpreter, which would be displayed by entering a statement:
import this
Principles will be printed as follow:
- Beautiful is better than ugly.
- Explicit is better than implicit.
- Simple is better than complex.
- Complex is better than complicated.
- Flat is better than nested.
- Sparse is better than dense.
- Readability counts.
- Special cases aren't special enough to break rules.
- Although practicality beats purity.
- Errors should never pass silently.
- Unless explicitly silenced.
- In the face of ambiguity, refuse the temptation to guess.
- There should be one- and preferably only one -obvious way to do it.
- Although that way may not be obvious at first unless you're Dutch.
- Now is better than never.
- Although never is often better than right now.
- If the implementation is hard to explain, it's a bad idea.
- If the implementation is easy to explain, it may be a good idea.
- Namespaces are one honking great idea -- let's do more of those!
conversing with Python
Before you can converse with Python, you have to first install the Python software from here [4] (choose between Python2 or Python3).After downloading, installing and add Python to the path variable, you will be in a terminal or command window and you will type Python and the Python Interpreter will start executing in interactive mode and appear somewhat as follows:
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
The >>> prompt is Python interpreter's way to ask you 'what you want to do?'. Python is ready to have a conversation with you. All you have to know is the language that Python understand which is definitely Python.An Example of a conversation with Python2 is:
>>> print 'Hello world!'
Hello world!
An Example of a conversation with Python3 is :
>>> print('Hello world!')
Hello world!
The proper way to say goodbye to Python is to enter quit() at the interactive chevron >>> prompt.
strengths
- Python supports object-oriented programming and Structured programming like Java, C++, and other OOP(Object-oriented Programming) languages.
- Python's clean, readable syntax makes code easily readable.
- Python provides good support for objects, modules, and other reusability mechanisms.
- Python can be easily integrated with and extensibility using C and Java.
- Python has a very strong open source community of users that interact through user groups and conferences.
- Python programs require a shorter development cycle as compared to other languages like Java and c++.
- Python is supported on major operating systems like Windows, Linux, Solaris and Mac OS X.
- Python has larger community and commercial support, a great advantage over other languages.
- Python is a scripting language which supposed to be a good reason to make Python strong because an empirical study found out that scripting languages are more productive than conventional languages (such as C and JAVA) for programming problems involving string manipulation and search in a dictionary.
Weaknesses
- Python 3.0 is not compatible with earlier versions making it difficult to migrate from earlier releases.
- Python is slower than languages like java and c++.
- Python is weak in mobile computing.
- Python lacks in performance for memory intensive tasks.
- Questionable support for parallel and multithreading programming.
- UI experience is weaker than Java.
- Python has a small number of developers compared to JAVA.
The future of Python
Many people are learning Python. Python is currently the most popular language for teaching introductory computer science courses at top-ranked U.S. departments. Python is open source, this one is really important point where Python leads on other languages. Even Python's creator, chose to stop working on or supporting Python, anyone could jump right in and continue working. All in all, We can say Python will continue to be used for a long time. Python is a very robust language that will continue to be used for decades to come.
Criticism
The greatest criticism of Python among developers is the release of version 3.0 without compatibility with earlier versions. Porting code from earlier versions is difficult and expensive. Furthermore, it is confusing to maintain two versions and it creates confusion over which one to learn.
Python reserved words [5]
Python has 31 reserved words which one has a specific mean in a python script and can't be used as a variable name or any other use, just the purpose it is built for.
and del from not while
as elif global or with
assert else if pass yield
break except import print
class exec in raise
continue finally is return
def for lambda try
Syntax and semantics[6]
Python language has many similarities to Perl, C, & Java. Python has a relatively uncluttered visual layout and uses English keywords frequently where as other languages use punctuation and Python is designed to be highly readable language. Python aims towards simplicity and generality in the design of its syntax.
Python Basic Syntax
- Indentation in Python is so important because Python uses white space indentation, rather than curly braces or keywords, to delimit blocks; this feature is also termed the off-side rule. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block.
- # means a comment in Python.
- There is nothing at the end of every statement in the code unlike java and C++ use semicolon at the end of every line code.
- 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.
- The semicolon(;) allows multiple statements on the single line given that neither statement starts a new code block.
Variables
- Everything in Python is an Object.
- Variables in Python are case-sensitive. Python treats 'case' and 'Case' as separate, unrelated entities.
- Python variables don't need explicit declaration to reserve memory space.The declaration happens automatically when assignment.
- The equal sign (=) is used to assign values to variables.
- Variables names must begin a letter.
- Python allows you to assign a single value to several variables simultaneously.
- Standard data types in Python are (Boolean, Number, String, Tuple, List, Dictionary).
- Number data type has four types in Python (Integer, Float, Long, Complex).
Data Types
- Boolean type has only a value True or False.
- Integer type is used to represent signed integers.
- Long type is used to represent long integers.They can also be represented in octal and hexadecimal.
- Complex type is used to represent complex numbers.
- Python use single quote (' ') or double quote (" ") to represent a string.
- Python use triple quot notation as a multi-line string("""multi-line string""").
- List: a sequence of values that can be any type and they are indexed by integers.Lists are mutable.
>>> list1 = [1,2,3,4,5,6,7]
>>> print list1[5]
6
- Tuple: is a sequence of values much like a list the values stored in a tuple can be any type and they are indexed by integers. The important difference is that tuples are immutable. Tuples are also comparable and hashable so we can sort lists of them and use tuples as key values in Python dictionaries. Tuples can be defined as a read-only list.
>>> tpl = (1,2,3,4,5,6,7)
>>> print tpl[5]
6
- Dictionary: are kind of hash table type.They work like associative arrays or hashes found in Perl and consist of key-value pairs.A dictionary key can be almost any Python type, but are usually numbers or strings.Values, on the other hand, can be any arbitrary Python object.
>>> d = {1:'ahmed' , 2:'david', 3:'jack'}
>>> print d[3]
jack
- Some types in Python are immutable which means it cannot be modified after it is created like (str, bytes, tuple, int, float, complex, boolean).
- Some types in Python are mutable which means it can be modified after it's created like (list, set, dict).
Operators
- There are about 7 types of operators in Python (Arithmetic, Comparison, Assignment, Logical, Bit-wise, Membership, Identity).
- Arithmetic Operators are (+ Addition, - Subtraction, * Multiplication, / Division, % Modulus, ** Exponential, // Integer Division )
- The modulus operator (%) works on integers and yields the remainder when the first operand is divided by the second.(EX: 9 % 2 = 1).
- Comparisons Operators compare the values on each side and return a boolean value (True or False).
- Comparisons Operators are (== If-equal, != not-equal, <> not-equal, < less-than, > greater-than, >= greater-than-or-equal, <= less-than-or-equal)
- Assignment Operators are used to assign value to a variable.
- Assignment Operators are (= assign, += Add and assign, -= subtract and assign, *= multiply and assign, /= divide and assign, %= modulus and assign, **= exponent and assign, //= integer divide and assign).
- Bit-Wise Operators are used to deal with bits and perform bit by bit operations.
- Bit-Wise Operators are (& Binary AND, | Binary OR, ^ Binary XOR, ~ Binary Ones Complement, << Left Shift, >> Right Shift)
- Logical Operators are (and Logical AND, or Logical OR, not Logical NOT).
- Membership Operators are used to test for membership in a sequence such as strings, lists, or tuples.
- Membership Operators are (in, not in).
>>> 'a' in 'banana'
True
>>> 'seed' in 'apple'
False
- Identity Operators are used to compare the memory locations of two objects.
- Identity Operators are (is , is not).
>>> 'banana' is 'banana'
True
>>> 'seed' is 'apple'
False
Rules of precedence
- When more than one operator appears in an expression, the order of evaluation depends on the rules of precedence.
- parentheses have the highest precedence and can be used to force and expression to evaluate in some order.
- Exponential has the next highest precedence.
- Multiplication and Division have the same precedence, which is higher than Addition and Subtraction which also have the same precedence.
- Finally operators with the same precedence are evaluated from left to right.
Conditional Execution
- The if statement, which conditionally executes a block of code based on a value of a boolean expression.
- If the expression is True, the block of code will be executed.
- If statement can be followed by an optional else statement which executes when the boolean expression is False.
- If statement can be followed by an optional elif (abbreviation for else if) block with a new expression to be evaluated.
Loops
- The while loop repeats a statement(s) while a given condition is True. It tests the condition before executing the statement(s).
- The for loop executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.
- You can use one or more loop inside any other while, for or do..while loop.
- The break statement, which used to terminate the loop and transfers execution to the statement that follows the loop.
- The pass statement used to create an empty block.
- Continue statement may only occur syntactically nested in a for or while loop, but not nested in a function of class definition or finally clause within that loop. It continues with the next cycle of the nearest enclosing loop.
- The yield statement is only used when defining a generator function and is only used in the body of the generator function. When a generator function is called, it returns an iterator known as a generator iterator or more commonly a generator. The body of the generator function is executed by calling the generator's next method repeatedly until it raises an exception. When a yield statement is executed, the state of generator is frozen and the value of expression list is returned to next caller.the function can proceed exactly as if the yield statement were just another external call.
Functions
- Function is a block of organized, reusable code that's used to perform an action.
- Function blocks begin with the keyword def followed by the function name and parentheses.
- Arguments of a function should be placed within these parentheses. You can also define parameters inside these parentheses.
- The first statement of a function can be an optional statement - the documentation string of the function or docstring.
- The coded block within every function starts with a colon (:) and is indented.
- Return statement leaves the current function call with the expression list or None as return value.
- The statement return [exp] exits a function, optionally passing back an expression to the caller.
- A return statement with no arguments is the same as return None.
- Void function is a function that doesn't return anything.
- Python has many built-in functions that you can use directly without defining them.
- Built-in function max (returns the largest number in a list).
- Built-in function min(returns the smallest number in a list).
- Built-in function len(returns the length of a collection).
- Built-in function map(apply a defined function to a list and return the updated list).
- Built-in function filter(filter out elements of list that have the value False from a defined function).
- The Anonymous Function is a function which is not declared in the standard manner by using def but declared by using lamda keyword.
- Lamda forms can take any number of arguments but return just one value in the form of an expression.
- Lamda can't contain commands or multiple expressions.
- Local variables can be accessed only inside the function in which are declared.
- The global statement is a declaration which holds for the entire current code block.It means that the listed identifiers are to be interpreted as globals. It would be impossible to assign to a global variable without global, although free variables may refer to globals without being declared global. Names listed in a global statement must not be used in the same code block textually preceding that global statement.
Python Exception Handling
- Exception is a Python object that represents an error.
- When a Python script raises an exception, it must either handle the exception immediately otherwise it terminates and quits.
- try/except: The idea of try and except is that you know that some sequence of instructions may have a problem and you want to add some statements to be executed if an error occurs. These extra statements (the except block) are ignored if there is no error.
- A single try statement can have multiple except statements. This is useful when the try block contains statements that may throw different types of exceptions.
- You can also provide a generic except clause, which handles any exception.
- After the except clause(s), you can include an else-clause. The code in the else-block executes if the code in the try: block does not raise an exception.
- The else-block is a good place for code that does not need the try: block's protection.
- You can use a finally: block along with a try: block. The finally block is must execute, whether the try-block raised an exception or not.
- Assert statements are a convenient way to insert debugging assertions into a program, it takes a bool argument if it's false then raise an exception else continue.
Files I/O
- The print statement is the simplest way to produce output where you can pass zero or more expressions separated by commas. This function converts the expressions you pass into a string.
- The raw_input([prompt]) function reads one line from standard input and returns it as a string.
- The input([prompt]) function is equivalent to raw_input except that it assumes the input is a valid Python expression and returns the evaluated result to you.
- Using Python's built-in open() function, You can open a file for reading or writing. This function creates a file object which would be utilized to call other support methods associated with it. It takes file name and optionally (access mode, buffering).
- file_name argument is a string contains the file name to be accessed.
- access_mode argument determines the mode in which the file has to be opened.(r read-only, r+ read and write, w write, w+ write and read, a append, a+ append and read).
- The close() method of a file object flushes any unwritten information and closes the file object, after which no more writing can be done.
- The write() method writes any string to an open file.
- The read() method reads a string from an open file.
Python Object Oriented
- The class statement creates a new class definition. The name of the class immediately follows the keyword class followed by a colon.
- Python uses __init__(self) as a constructor function in a class which is called when an instance of the class is created, self-refers to the instance like "this" in java and C#, this function more arguments.
- To create instances of a class, you call the class using name and pass in whatever arguments its __init__ method accepts.
- You access the object's attributes using the dot operator with object.
- Methods on object are functions attached to the object's class, the syntax instance.method(argument) is, for normal methods and functions, syntactic sugar for Class.method(instance, argument). Python methods have an explicit self-parameter to access instance data called self (or this) in other programming languages (e.g. C++, C# and java)
- you can create a class by deriving it from a preexisting class by listing the parent class in parentheses after the new class name.The child class inherits the attributes of its parent class, and you can use those attributes as if they were defined in the child class.A child class can also override data members and methods from the parent.
- An object's attributes may or may not be visible outside the class definition. You need to name attributes with a double underscore prefix and those attributes then are not be directly visible to outsiders.
Regular Expression
- A regular expression is a special sequence of characters that helps you match or find other strings or sets of strings using a specialized syntax held in a pattern.
- The module re provides full support for perl-like regular expression in Python.
- re.match(pattern, string, flags=0) attempts to match RE pattern to string with optional flags.
- re.search(pattern, string, flags=0) searches for first occurrence of RE pattern within string with optional flags.
Python Modules
- A module is a Python object with arbitrarily named attributes that you can bind and reference.
- The import statement used to import a module to be used.
- When the interpreter encounters an import statement, it imports the module if the module is present in the search path.
- A search path is a list of directories that the interpreter searches before importing module.
- Python's from statement lets you import specific attributes from a module into the current namespace.
- It's also possible to import all names from a module into the current namespace by using from modname import *.
- The dir() built-in function returns a sorted list of strings containing the names defined by a module.
"Hello World" Example
Python2
print "Hello world"
Python3
print("Hello world")
Advanced Examples
Summation of elements in a list
#you can use the built-in function 'sum' to get the summation of a collection of numbers (integers and floats).
given_lst = [5, 3, 2, 1, 6, 7, 8, 9, 55, 4, 3, 5, 5]
print "Summation of elements of the given_lst is ", sum(given_lst)
Another way to achieve that
# initialize a list of integers
given_lst = [5, 3, 2, 1, 6, 7, 8, 9, 55, 4, 3, 5, 5]
#initialize summation variable with zero
summation = 0
#iterate over the items of given_lst list
for lst_item in given_lst:
#summation = last value of summation variable(initialized by 0) + value of the current item
summation += lst_item
print "summation of elements of the given_lst is ",summation
The output summation will be 113 for both examples.
Grade Calculation
A Python script to calculate a student grade based on the following table:
Score | >= 0.9 | >= 0.8 and < 0.9 | >= 0.7 and < 0.8 | >= 0.6 and < 0.7 | < 0.6 |
---|---|---|---|---|---|
Grade | A | B | C | D | F |
# ask the user to enter a score. score_inp variable type is string so we need to convert it to float before processing
score_inp = raw_input("Enter your score between [0-1]:")
# use try keyword to catch any exception occur.
try:
# convert score_inp from string to float
# it may throw an exception if the user entered a non number value.
score = float(score_inp)
#initialize grade variable with an empty string
grade = ""
#check if the score is outside [0-1] then raise an exception to be caught in except clause.
if score > 1.0 or score < 0.0:
#raise an exception using raise keyword.
raise
# check if the score >= 0.9 then the grade will be A
elif score >= 0.9:
grade = "A"
# check if the score >= 0.8 then the grade will be B
elif score >= 0.8:
grade = "B"
# check if the score >= 0.7 then the grade will be C
elif score >= 0.7:
grade = "C"
# check if the score >= 0.6 then the grade will be D
elif score >= 0.6:
grade = "D"
# then the score will be < 0.6 so the grade will be F
else:
grade = "F"
print "Your grade is :",grade
# will be executed if something wrong happened above
except:
print "Error, wrong score value."
Max Value
#you can use the built-in function 'max' to get the max value within a collection of numbers (integers and floats).
given_lst = [5, 3, 2, 1, 6, 7, 8, 9, 55, 4, 3, 5, 5]
print "Maximum element withen the given_lst is ", max(given_lst)
Another way to achieve that
# define a list of integers.
given_lst = [5, 3, 2, 1, 6, 7, 8, 9, 55, 4, 3, 5, 5]
# initialize the maximum value with the first element in the list.
max_value = given_lst[0]
# iterate over items of the given list
for item in given_lst:
# check if the current item is greater than the value in the max_value variable.
if item > max_value:
# update the value of max_value with the current item which is greater than max_value
max_value = item
print max_value
Searching
#you can use the keyword in which return a boolean value whether a value exists in a collection or not
given_lst = [5, 3, 2, 1, 6, 7, 8, 9, 55, 4, 3, 5, 5]
print "Is the list has the value 5? ", 5 in given_lst
print "Is the list has the value 20? ", 20 in given_lst
Another way to achieve that it's called Sequential search:
# define a list of integers
given_lst = [5, 3, 2, 1, 6, 7, 8, 9, 55, 4, 3, 5, 5]
# the value we will search for
key = 8
# initialize the found flag with false
found_flag = False
#iterate over items of the given list
for item in given_lst:
# check if the current item is equal to the value we search for
if key == item:
# update the found flag to True(founded)
found_flag = True
# get out of the loop because the value is found
break
print found_flag
If we have a previous knowledge that the list is sorted, we can do the search by a more efficient way called Binary Search.
def binary_search(given_list, key, first_index = 0, last_index = None):
"""
search for a key in a given list and return its index if found, -1 otherwise.
"""
# initialize the last_index variable with the length of the list only if it's None.
if last_index is None:
last_index = len(given_list)
# iterate until first_index is no more less than last_index.
while first_index < last_index:
# initialize middle variable with the index of the item in the middle of first and last index.
middle = (first_index + last_index) // 2
# search for the key in the items from middle + 1 to last item.
if given_list[middle] < key:
first_index = middle + 1
# search for the key in the items from first_index to middle.
elif given_list[middle] > key:
last_index = middle
else:
# key is found, return key's index.
return middle
# key is not found, return -1.
return -1
print binary_search([1, 3, 5, 10, 11, 23, 44], 23) # output : 5
print binary_search([5, 10, 20, 40, 66], 5) # output : 0
print binary_search([5, 10, 20, 40], 7) # output : -1
Sorting
# you can use the built-in function '''sorted()''' to sort a list of numbers or stings.
given_list = [5, 3, 2, 1, 6, 7, 8, 9, 55, 4, 3, 5, 5]
print "A sorted version of given_list is ", sorted(given_list)
A brute force implementation of sorting is as following:
def sort_list(list_input):
"""
return a sorted version of the input list without mutate it.
"""
# initialize the resulting list with an empty list.
result_lst = list()
# copy the list_input to temp variable not to mutate the input list.
inp_tmp = list(list_input)
# iterate while inp_tmp has no elements.
while len(inp_tmp) > 0:
# get the minimum value in the input list and add it to the result list at the tail.
result_lst.append(min(inp_tmp))
# remove the element was just added from inp_tmp list.
inp_tmp.remove(result_lst[-1])
# return the sorted version of the input list.
return result_lst
print sort_list([5, 3, 2, 1, 6, 0, 7, 8, 9, 55, 4, 3, 5, 5])
we can do the sorting by a more efficient way called Merge Sort.
def merge(lst1,lst2):
"""
merge 2 lists of elements and return a single sorted list.
"""
# initialize 2 index variables one for each list with zero.
index1 = 0
index2 = 0
# initialize the resulting list as an empty list.
result = list()
# iterate until reach the end of one of the two lists.
while index1 < len(lst1) and index2 < len(lst2):
# add each item in the 2 lists to the result list and keep it sorted.
if lst1[index1] <= lst2[index2]:
result.append(lst1[index1])
index1 += 1
else:
result.append(lst2[index2])
index2 += 1
# add the rest of the items in the first list that weren't added yet(if the first index didn't reach the limits).
while index1 < len(lst1):
result.append(lst1[index1])
index1 += 1
# add the rest of the items in the second list that weren't added yet(if the second index didn't reach the limits).
while index2 < len(lst2):
result.append(lst2[index2])
index2 += 1
return result
def merge_sort(lst):
"""
return a sorted version of the input list.
"""
# if the lst has a single item, so it's sorted then return it.
if len(lst) < 2:
return lst
# initialize the middle variable with the index of the item in the middle in input list.
middle = len(lst) // 2
# use recursive to sort the elements on the left of the middle index.
left_lst = merge_sort(lst[:middle])
# use recursive to sort the elements on the right of the middle index.
right_lst = merge_sort(lst[middle:])
# call merge function to merge the left and right lists and return a sorted list.
return merge(left_lst, right_lst)
print merge_sort([5, 3, 2, 1, 6, 0, 7, 8, 9, 55, -1, -66, 4, 3, 5, 5])
# it works also on list of strings.
print merge_sort(['jack', 'leo', 'ronaldo', 'roberts'])
Python Libraries [7]
As of January 2016, The Python package index, The official repository of third-party software for Python, contains more than 72000 packages offering a wide range of functionality (That what makes Python so powerful) including:
- Web-programming : Django (web framework)[11], Pyramid[12], Bottle[13], Tornado[14], Flask[15], web2py[16], Pylons[17], TurboGrears[18], zope[19]
- Web Scrapping : scrapy[23], Beautiful Soup[24], urllib[25]
- Testing : nose[32]
- Mathematics : Saga[44]
Development Environment
Most Python scripts can be executed as a command line interpreter that the user enter the statement and receive the output immediately(Python act like a shell). It can be done by many ways:
- Standard desktop Python IDEs(integrated development environments)
- Browser-based IDEs
- Saga, intended for developing science and math-related Python programs.
- Browser-based IDE and hosting environment, PythonAnyWhere.
Implementation
The main Python implementation (CPython) is written in C. It compiles Python programs into intermediate bytecode, which is executed by virtual machine. CPython is distributed with a large standard library written in C and Python.
PyPy is a fast interpreter for Python 2.7 and 3.2.its just in time compiler brings a significant speed improvement over CPython. A version that takes advantage of multi processors using software transactional memory is being created.
Stackless Python is a significant fork of CPython that implements micro threads. It doesn't use the C memory stack, thus allowing massively concurrent programs. PyPy has also a stackless version.
There are many compilers to high-level object languages, with unrestricted Python or restricted subset of Python or a language similar to Python as the source language:
- Jython: compiles into java byte code, then it can be executed by every java virtual machine. This also enables the use of java class library functions from the Python program.
- IronPython: enables running Python programs on .NET common language Runtime.
- The RPython language can be compiled to C, java bytecode or common intermediate language and used to build PyPy interpreter of Python.
- Pyjamas:u sed to compile Python to JavaScript.
- Cython and Pyrex: used to compile Python to C.
- Shed Skin: used to compile Python to C++.
Python Enhancement Proposal[53]
Python Enhancement Proposal (PEP) is a documentation designed to provide information to the Python community or describing a new feature for Python or its process or environment. The PEP should provide a concise technical specification of the feature and a rationale for the feature.
We intend PEPs to be the primary mechanisms for proposing major new features, for collecting community input on an issue, and for documenting the design decisions that have gone into Python. The PEP author is responsible for building consensus within the community and documenting dissenting opinions.
In short it a formal design document for some new feature or major change to Python or something in the tools and standards around which the Python ecosystem revolves.
There are three kinds of PEP:
- A Standards Track PEP: describes a new feature or implementation for Python. It may also describe an interoperability standard that will be supported outside the standard library for current Python version before a subsequent PEP adds standard library support in a future version.
- An Informational PEP: describe a Python design issue or provide general guidelines or information to the Python community but does not propose a new feature. Informational PEPs don't necessarily represent a Python community consensus or recommendation so users and developers are free to ignore Informational PEPs or follow their advice.
- A Process PEP: describes a process surrounding Python or proposes a change to (or an event in) a process. Process PEPs are like Standards Track PEPs but apply to areas other than the Python language itself. They may propose an implementation but not to Python's codebase; They often require community consensus; unlike Informational PEPs, They are more than recommendations and users are typically not free to ignore them. Examples include procedures, guideline, changes to the decision-making process and changes to the tools or environment used in Python development. Any meta-PEP is also considered a Process PEP.
Best Practices
Some resources are listed as follows:
- How to Think Like a Computer Scientist Learning with Python: Interactive Edition 2.0 [54]
- Think Python vocabulary [55]
- The Python standard library [56]
- The Hitchhiker’s Guide to Python![57]
- The A-Z of Programming Languages: Python [58]
- Learning Python , 5th Edition Powerful Object-Oriented Programming [59]
- Programming in Python 3 (Second Edition) [60]
- Python for Everybody Specialization: Learn to Program and Analyze Data with Python[61]
Languages influenced by Python
Python's design concepts and syntax influenced many other programming languages, including:
- Swift: is a programming language created by Apple. It has some Python inspired syntax
- Ruby: is a scripting language that is more powerful than Perl, and more object-oriented than Python according to its creator Yukihiro Matsumoto said.
- Go: is described as incorporating the "development speed of working in a dynamic language like Python".
- Boo: uses indentation just like Python
- ECMAScript: uses iterator, generator and list comprehension just like Python.
- Groovy: desires to bring Python design philosophy to JAVA.
Feature comparison of Python and other data science tools [62]
Feature | R | Python | SAS | SPSS | STATA |
---|---|---|---|---|---|
Outlier diagnostics | Available | Available | Available | Available | Available |
Generalized linear models | Available | Available | Available | Available | Available |
Univariate time series analysis | Available | Available | Available | Limited | Available |
Multivariate time series analysis | Available | Available | Available | ||
Cluster analysis | Available | Available | Available | Available | Available |
Discriminant analysis | Available | Available | Available | Available | Available |
Neural networks | Available | Available | Available | Limited | |
Classification and regression trees | Available | Available | Available | Limited | |
Random forests | Available | Available | Limited | ||
Support vector machines | Available | Available | Available | ||
Factor and principal component analysis |
Available | Available | Available | Available | Available |
Boosting Classification & Regression Trees | Available | Available | Limited | ||
Nearest neighbor analysis | Available | Available | Available | Available |
Average Programmer Salaries
Country | Average Salary | Years of Experience |
---|---|---|
USA | 101,000(US$)[63] | 5 |
UK | 55,000(UK£) [64] | 2-5 |
Top Companies Providing Python Programming Services
- Google: is an American multinational company specialized in Internet-related services and products including advertising, search, cloud computing and software development.
- Yahoo: is an American multinational company globally known for its portal, search engine and related services.
- CERN: The European Organization for Nuclear Research derived from the name "Conseil Européen pour la Recherche Nucléaire"
- NASA: The National Aeronautics and Space Administration is the U.S government agency for the civilian space program as well as aeronautics and aerospace research.
- Industrial Light & Magic (ILM):[65] is an American motion picture visual effects company.It's a division of the film production company, LucasFilm which Lucas founded and was created when Lucas began production of the file 'Star Wars'.
- ITA Software:[66] is travel industry software division of Google, formerly an independent company in Cambridge , Massachusetts.
- Agiliq Info Solutions:[67] is an app development studio building web and mobile apps.
- Antonio Cuni:[68] is an expert of Python and PyPy core developer, based in Italy.
- Anubavam LLC:[69] is a San Antonio based Software development company with offices in Chennai , India.
- Art & Logic[70] is a software developer, providing Windows, Mac OS, and Web development services.
- Atrrios Ltd: is a Serbian software , graphics design , and R&D company based in Belgrade. Atrrios Ltd offers training and consulting services in the field of software development using Python programming language, computer network design and administration.
- BAT Systems: are system developers working in Python along side C/C++/Delphi/SQL (and others).
- BeClasp Consulting:[71] is a New Delhi, India based software development firm specializing in Python Development and Training.
- Cartwheel Web Development:[72] is a Los Angeles firm that specializes in Python and Django consulting. Python and Django classes, workshops, bootcamps, and hackathons are held at Cartwheel's San Fernando Valley office on a regular basis.
- Codemera:[73] is an independent software company made of people passionate about the Web, with skills within the realms of development, design and content.
- Codemyphd: is a Tech startup specialized in Python and dedicated to the scientific community.
- Code Sprinters: develops web applications in Python and other dynamic languages using agile methods (XP, Scrum).
- Continuum Analytics:[74] specializes in solving large-scale technical computing problems with an emphasis on data management, analysis, and visualization.
- Constant Time Dynamic DNS: offers custom consulting services in Python. They specialize in large-scale site administration tools development.
- CyberWeb Consulting:[75] serving Python training and software development needs which is Based in Silicon Valley and the San Francisco Bay Area.
- Dancing Bison Enterprises: The lead consultant, Vasudev Ram, is a member of Python Software Foundation.
- DjanSoft: is an agile software consulting company in Los Angeles specializing in web applications.
- eGenix.com: offers software, skills, and services for companies investing in Python.
- Engenuity Corporation:[76] builds custom industrial control and automation applications in Python. We offer a variety of consulting services, including training, project management, digital hardware design, automated test development, and more, and are happy to pass on to you our unique experience using Python for and in support of all of the above.
- Enthought, Inc: provides scientific computing solutions using Python. Custom application development, consulting, F/OSS package distribution and support, sponsorship of conferences (SciPy Conference) and tools development (code.enthought.com, scipy.org).
- GOF Consulting Pvt. Ltd: - India based Software Development company.
- Green Dragonfly LLC: has expertise in working on the core Python interpreter and in writing programmer-oriented documentation.
- Etienne Robillard: - Python developer based in Montréal. Employs Agile software development methodologies to deliver competitive and scalable solutions in Django.
- Heptacube R&D: is a software design studio in Montréal.
- Imaginary Landscape, LLC:[77] is a full-service Chicago web developer utilizing Python, Django and other open source technologies to create custom websites.
- Jason Davies: is an expert Python/Django developer based in London, UK.
- Lab 305:[78], located in the Hartford, CT area, provides Python and Django consulting services for projects of all sizes.
- Lights On Software:[79] - Django Developers, located in Toronto, Canada, provides Python and Django consulting.
- Lintel Technologies:[80], provides consulting in building end to end applications (from design to deployment) using Python and other opensource technologies.
- PSC Group LLC: Chicago based consulting agency specializing in Python.
- Match Strike: builds Django-based web applications from the ground up in San Francisco.
- Mindfire Solutions:[81] is an India based Software development company with offices in Delhi , Bhubaneswar India and USA offices in CA and MI. Mindfire Solutions provides a range of services on Python.
- 'Monico Technologies:[82]' is an IT company which provides IT solutions and services locally and internationally while residing in Bangladesh.
- NeuroKode Labs:[83] LLC provides consulting and custom development services utilizing Python, Jython, C/C++ and many other technologies. Of note is the open source project PDO - Python Database Objects.
- NobleProg Limited: offers bespoke consultancy services.
- Oceana Technologies:[84] is a Python / Django focused Full Stack Application Development coding firm located San Francisco.Bootstraps, Jquery as well as all libraries to make your projects come to life. Oceana Technologies - We write the code that runs your business.
- Pangur Pty Ltd: is an Australian (Melbourne) Python development company specializing in bespoke Python web solutions with a focus on scalability/extensibility.
- Phaseit:[85] provides Python programming, training, and related consulting services, particularly with Web services, StacklessPython, TurboGears, WebWare, Zope, and other Web-based application servers, and TkInter, PyQt, WxWindows, and other GUI toolkits.
- Piran Digital:[86], Python / Django specialists in Sydney, Australia.
- PixBuffer Software Inc:[87]. is a full-service software company specialized in complex web applications (including SaaS), custom web development and consulting.
- NOUS: is based in Lithuania and specializes in Python, pylons and zope web application development using agile methodologies.
- Programmers of Vilnius:[88], an agile software development company that specializes in web applications in Python, the Zope Toolkit , and Pylons. POV offers consulting, as well as custom software development services.
- Propylon:[89] Propylon provides software systems and business applications to support legal professionals in becoming more efficient in their role.provides Python programming, consulting and mentoring services particularly in the areas of XML, Java/Jython, Zope/Plone. Located in New York and Dublin, Ireland.
- Purple Bit:[90] is a software consultancy based in Israel, Tel Aviv. We provide development and consulting services for clients world-wide.
- PyGuys.com: is the Python-centric consulting arm of Botonomy LLC.
- Python Academy:[91] provides Python training, consulting, and programming.
- RadimRehurek.com: provides high-end custom development, consulting and company trainings for machine learning, data mining, and big data systems. Radim, an experienced consultant with PhD in NLP&ML and the author of the gensim machine learning Python library , leads a small , dedicated team of experts that has delivered state-of-the-art solutions to large multinational companies as well as small businesses and startups.
- Revolution Systems:[92] provides commercial support, training, custom development, and consulting for Django and Python.
- Script Foundry: develops tools and trading systems in Python. Using pso and working with IntegrationLab Script Foundry developed numerous serious trading tools for the NYSE production floor making Python the 4th NYSE production language (the others being cobol , C , C++ ).
- Secret Labs AB (PythonWare): is a company in software development with Python.
- Siddhatech:[93] is a web based software consulting company in Pune , India specializing in web applications.
- Sixty North:[94] is a software development company based in Norway.They offer Python consulting and training services worldwide , with specific expertise in scientific, oil & gas, and geospatial topics as well as C++/Python integration.
- Sprymix Inc: is a team of Python developers in Toronto, specializing in custom system and web development, integration, and related services. Particular areas of expertise include backend and frontend Web development (custom systems, Django, Flask), big-data processing and modeling, code analysis.
- Stochastic Technologies:[95] is a software development company based in the UK.
- The Penguin and The Python: is a boutique consulting firm based outside of San Francisco. They specialize in Python and Linux consulting , including custom Python programming.
- ThinkwareAB: offers programming, mentoring and training with Python. They are located in Sweden.
- Tivix:[96] is a Silicon Valley based, custom Django/Python Development shop.
- Varsys Inc:[97] is a Chicago-based software development company offering full spectrum of development services.
- Velotron Heavy Industries:[98] provides solutions for environmental data collection, processing, and analysis , with an emphasis on Python software.
- Vex Consulting Incorporated: is a Toronto-based company, incorporated in 2006, specializing in ISP Management.
- VT Enterprise LLC: (estd. in 2001 in Jersey City, NJ) writes enterprise software and provides consulting services for the financial industry.
- Testled Ltd: - Fleet, United Kingdom build business applications with Python.
- Sphere Consulting: provides Agile custom application development (in Python, Ruby on Rails, .NET, LAMP, Java, and iPhone) and business intelligence solutions.
- Vinta Software Studio: is a software shop from Brazil specialised in full-stack web development with Django , Django REST Framework on the backend and React or AngularJS on the frontend.
Top 5 Recent Tweets
Top 5 Lifetime Tweets
Date | Author | Tweet | link |
---|---|---|---|
3 Nov 2015 | @PythonWeekly | Python 0.4 released: http://blog.pyston.org/2015/11/03/102/ Looks like solid progress! | https://twitter.com/gvanrossum/status/661633068386484225 |
References
- ↑ https://www.python.org/about/apps/
- ↑ http://groups.engin.umd.umich.edu/CIS/course.des/cis400/python/python.html
- ↑ http://svn.python.org/view/*checkout*/python/trunk/Misc/HISTORY
- ↑ https://www.python.org/downloads/
- ↑ https://docs.python.org/2.5/ref/keywords.html
- ↑ https://docs.python.org/2/tutorial/index.html
- ↑ https://www.python.org/about/apps/
- ↑ https:///www.w3schools.com/xml/
- ↑ https:///www.w3schools.com/html/
- ↑ https:///www.w3schools.com/json/
- ↑ https://docs.djangoproject.com/en/1.9/intro/tutorial01/
- ↑ http://pyramid-tutorials.readthedocs.org/en/latest/getting_started/
- ↑ https://www.bottlepy.org/docs/dev/tutorial.html
- ↑ https://www.tornadoweb.org/
- ↑ https://www.flask.pocoo.org/docs/latest/tutorial/
- ↑ https://www.web2py.com/book/default/chapter/01
- ↑ https://www.pylonsbook.com/en/1.1/introducing-pylons.html
- ↑ https://www.turbogears.readthedocs.org/
- ↑ https://www.docs.zope.org/zope2/zdgbook/
- ↑ https://docs.python.org/2/library/sqlite3.html
- ↑ https://wiki.postgresql.org/wiki/Psycopg2_Tutorial
- ↑ https://www.docs.sqlalchemy.org/en/latest/orm/tutorial.html
- ↑ https://www.doc.scrapy.org/en/latest/intro/tutorial.html
- ↑ https://www.web.stanford.edu/~zlotnick/.../Web_Scraping_with_Beautiful_Soup.html
- ↑ https://docs.python.org/2/howto/urllib2.html
- ↑ https://www.effbot.org/imagingbook/
- ↑ https://www.pillow.readthedocs.org/en/3.0.x/handbook/tutorial.html
- ↑ https://docs.python.org/2/howto/sockets.html
- ↑ https://docs.python.org/2/howto/urllib2.html
- ↑ https://pygame.org/wiki/tutorials
- ↑ https://www.pyglet.readthedocs.org/en/latest/programming_guide/quickstart.html
- ↑ https://www.pythontesting.net/framework/nose/nose-introduction/
- ↑ https://www.zetcode.com/wxpython/
- ↑ https://www.zetcode.com/gui/tkinter/
- ↑ https://python-gtk-3-tutorial.readthedocs.org/
- ↑ https://www.python-gtk-3-tutorial.readthedocs.org/en/latest/introduction.html
- ↑ https://wiki.python.org/moin/PyQt/Tutorials
- ↑ https://wiki.qt.io/PySide_Tutorials
- ↑ https://www.docs.scipy.org/doc/scipy/reference/tutorial/
- ↑ https://www.pandas.pydata.org/pandas-docs/stable/tutorials.html
- ↑ https://ipython.org/ipython-doc/2/interactive/tutorial.html
- ↑ https://docs.scipy.org/doc/numpy-dev/user/quickstart.html
- ↑ https://www.matplotlib.org/users/pyplot_tutorial.html
- ↑ https://www.saga-python.readthedocs.org/
- ↑ https://www.docs.buildbot.net/current/tutorial/
- ↑ https://www.trac.edgewall.org/wiki/TracInstall
- ↑ https://pypi.python.org/pypi/roundup
- ↑ https://www.scons.org/doc/1.1.0/HTML/scons-user/book1.html
- ↑ https://gump.apache.org/
- ↑ https://www.docs.ansible.com/developing_api.html
- ↑ https://www.salt.readthedocs.org/en/v0.9.2/topics/tutorial.html
- ↑ https://www.developer.openstack.org/api-guide/quick-start/
- ↑ https://www.python.org/dev/peps/
- ↑ http://interactivepython.org/runestone/static/thinkcspy/index.html
- ↑ http://www.memrise.com/course/173951/think-python-vocabulary/
- ↑ https://docs.python.org/2/library/functions.html#map
- ↑ http://docs.python-guide.org/en/latest/
- ↑ http://www.computerworld.com.au/article/255835/a-z_programming_languages_python/
- ↑ http://shop.oreilly.com/product/0636920028154.do
- ↑ http://www.qtrac.eu/py3book.html
- ↑ https://www.coursera.org/specializations/python
- ↑ http://stanfordphd.com/Statistical_Software.html
- ↑ http://marketing.dice.com/pdf/Dice_TechSalarySurvey_2015.pdf
- ↑ http://www.itjobswatch.co.uk/jobs/uk/python%20developer.do
- ↑ https://www.ILM.com
- ↑ https://www.ITAsoftware.com
- ↑ https://agiliq.com/
- ↑ https://antocuni.eu/
- ↑ https://www.anubavam.com/
- ↑ https://artandlogic.com/
- ↑ https://beclaspconsulting.net/
- ↑ https://www.cartwheelweb.com/
- ↑ https://codemera.com/
- ↑ https://www.continuum.io/
- ↑ https://cyberwebconsulting.com/
- ↑ http://www.engcorp.com/
- ↑ https://www.imagescape.com/
- ↑ https://www.lab305.com/
- ↑ https://www.lightsonsoftware.com/
- ↑ https://www.lintelindia.com/
- ↑ https://www.mindfiresolutions.com/
- ↑ https://www.monicotechnologies.com/
- ↑ https://www.neurokode.com/
- ↑ https://www.oceanatech.com/
- ↑ https://www.phaseit.net/
- ↑ https://www.piran.com.au/
- ↑ https://www.pixbuffer.com/
- ↑ https://www.pov.lt/
- ↑ https://www.propylon.com/
- ↑ https://www.purplebit.com/
- ↑ https://www.python-academy.com/
- ↑ https://www.revsys.com/
- ↑ https://www.siddhatech.com/
- ↑ https://www.sixty-north.com/
- ↑ https://www.stochastic.io/
- ↑ https://www.tivix.com/
- ↑ https://www.varsys.com/
- ↑ https://www.velotronheavyindustries.com/