background preloader

Python programming

Facebook Twitter

The Python Tutorial Python v2.7.2 documentation. Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.

The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python web site, and may be freely distributed. The same site also contains distributions of and pointers to many free third party Python modules, programs and tools, and additional documentation. The Python interpreter is easily extended with new functions and data types implemented in C or C++ (or other languages callable from C). This tutorial introduces the reader informally to the basic concepts and features of the Python language and system. Google's Python Class - Google's Python Class - Google Code. Welcome to Google's Python Class -- this is a free class for people with a little bit of programming experience who want to learn Python. The class includes written materials, lecture videos, and lots of code exercises to practice Python coding.

These materials are used within Google to introduce Python to people who have just a little programming experience. The first exercises work on basic Python concepts like strings and lists, building up to the later exercises which are full programs dealing with text files, processes, and http connections. The class is geared for people who have a little bit of programming experience in some language, enough to know what a "variable" or "if statement" is. Beyond that, you do not need to be an expert programmer to use this material. This material was created by Nick Parlante working in the engEDU group at Google. Special thanks for the help from my Google colleagues John Cox, Steve Glassman, Piotr Kaminksi, and Antoine Picard.

Python Programming - Wikibooks, open books for an open world. Python Programming From Wikibooks, open books for an open world Jump to: navigation, search This book describes Python, an open-source general-purpose interpreted programming language available for a broad range of operating systems. There are currently three major implementations: the standard implementation written in C, Jython written in Java, and IronPython written in C# for the .NET environment.

Contents[edit] Intro[edit] Overview Getting Python Setting it up Interactive mode Self Help Basics[edit] Creating Python programs Variables and Strings Basic syntax Sequences (Strings, Lists, Tuples, Dictionaries, Sets) Data types Numbers Strings Lists Tuples Dictionaries Sets Basic Math -- redundant to "Operators" Operators Control Flow Decision Control Conditional Statements Loops Functions Scoping Input and output Files Text Modules Classes Exceptions Errors Source Documentation and Comments Idioms Advanced[edit] Decorators Context Managers Reflection Metaclasses Namespace Tips and Tricks Modules[edit] Standard library modules[edit] Sthurlow.com - Home. How to Think Like a Computer Scientist. 2. Built-in Functions Python v2.7.2 documentation. Open a file, returning an object of the file type described in section File Objects. If the file cannot be opened, IOError is raised. When opening a file, it’s preferable to use open() instead of invoking the file constructor directly.

The first two arguments are the same as for stdio‘s fopen(): name is the file name to be opened, and mode is a string indicating how the file is to be opened. The most commonly-used values of mode are 'r' for reading, 'w' for writing (truncating the file if it already exists), and 'a' for appending (which on some Unix systems means that all writes append to the end of the file regardless of the current seek position).

If mode is omitted, it defaults to 'r'. The default is to use text mode, which may convert '\n' characters to a platform-specific representation on writing and back on reading. Modes 'r+', 'w+' and 'a+' open the file for updating (reading and writing); note that 'w+' truncates the file. Python Examples. On these pages, I have collected a bit of information about the Python programming language, along with a bunch of examples. These might be useful if you want to see some of the features without actually learning the language itself. You don't have to read through all of this in order. Just pick the pages which look most interesting to you. The topics are fairly independent from each other and don't require any existing knowledge about Python.

Note: Some of the examples might require at least Python 2.3. Small code examples This page contains a few small code snippets, to give you an impression how the programming language looks like. Lambda functions Several useful concepts of Python have been borrowed from functional languages. Dynamic typing In Python, everything has a well-defined type, and these types can be handled completely at runtime in a dynamic and self-inspective fashion. Structured types List comprehensions Block indentation Python Tutorial - Read this one first!!!