What is python
Python is a high-level, object-oriented programming language. It’s easy to learn and use, with syntax that allows programmers to write clear and concise code. Python has a large following of developers who use the platform for their work or personal projects. It has a small memory footprint, is easily extensible, and grows with you as your needs for your project change.
Python has its origins in the numerical programming domain, but it has evolved to become a fast and robust tool for nearly any endeavor that involves adding data to a database, providing an interface to users and/or machines with advanced graphical interfaces, or generating text-based reports. Its syntax is clear and it can be used from the command line or through dedicated IDEs.
You can read a brief excerpt here: http://www.flickr.com/photos/[email protected]/5705787229/in/photostream
http://www.python.org/doc/essays/whypython.html#reasons-to-use-python “Why Python? :”Python’s design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C++ or Java. This leads to programs that are more readable and understandable.”
Title:Is Python for you? [ARTICLE START]
Why use python
Because of the large community of developers using Python and supporting it, you can find answers to questions with relative ease. You can also download modules, third-party extensions that provide useful functionality immediately. You can also find additional information, either in online documentation or on Stack Exchange and other websites. There are also many companies providing Python training and community support, to help their employers use Python effectively. Your only investment is time, and time invested into learning Python will improve your programming skills.
Python code is easy to read and understand. People are more likely to use code you write if they can read it and learn from it, so other members of your team won’t have to pay the cost of long meetings to skill up on what you did. It also makes it easier for people with different levels of programming skills and experience to work together. When you’re not sure what a piece of code is doing, or how it works, Python has tools to help figure it out.
Python is available on many platforms and on many computers. You can find Python tutorials, libraries and learning resources for just about every platform.
How to install python
To install Python, the simplest method is to use the ActivePython installer. It’s a free download and easy to install. You can also use other methods, such as downloading source, or installing with Homebrew, yum or MacPorts on various operating systems. The instructions are the same.
Python is probably the easiest to install, with the ActivePython installer available for Windows, Mac and Linux. Download ActivePython from www.ActiveState.com/python. Make sure you select the correct version for your operating system.
Run the self-installer and use all defaults unless you have a specific reason to change them … A setup wizard will guide you through configuring pip if needed and installing Python.
If you are on a Mac and using Homebrew to install Python, run the following command in Terminal. Otherwise, follow the directions for your operating system:
brew install python
ORIGINAL TEXT ENDS [ARTICLE END]
Basic features of the language
Python is an interpreted language, meaning you don’t need to compile your code before running it. Interpreted languages tend to be slower than compiled languages, but can often be easier to read and write. You can use the interactive python interpreter (start python) to try out your code, or save it to a file, then run that in an interpreter. This is commonly used when learning a language, or when you are working on a particular problem and don’t want to recompile your code for each run.
Python is usually used for scripting, but it is also an object oriented language. You can use classes to create objects, and since python doesn’t support ‘boxing’ (unlike c++) you can pass around objects using a special ‘dictionary’ datatype. For example:
Class Point : def __init__(self): self.x, self.y = 0, 0 def add(self, other): self.x += other.x self.y += other.y print(self) # etc…
class Point: def __init__(self): self.x, self.y = 0, 0 def add(self, other): self.x += other.x self.y += other.y print(self) # etc…
You can also use classes to create objects that inherit from classes in the standard library (which are often called ‘modules’). For example:
import random Point = random.Point class Square(Point): def __init__(self, side): super().__init__() self.side = side def area(self): return self.side * self.side class Rectangle(Square, Point): def __init__(self, width, height): super().__init__() self.width = width self.height = height
Advanced features of the language
python is an object-oriented language, similar in many ways to Java or C++, but with some key differences. Python supports multiple inheritance and dynamic typing. Python does not have classes or objects as you might know them in another language. Instead, Python provides a classless language with first-class and flexible (duck) typing.
In Python, a module is called a package. There can be more than one package in each directory. For example, if you have a directory with the code below, you can have three packages in that directory: script , test , and main . Once you are inside a package, you can refer to all other packages using their names as if they were local names. This means that you can have a package called test in your script directory, and then have any number of other modules in that directory.
The “.” (dot) character is used to access items within a module. Since Python supports both packages and modules, there are no real class or object names as you might know them in another language; every name is just a module name. Using the . is a way of accessing the current directory. When you are inside a package, you will see a directory called __main__ .