Python Utilities - Educational Materials In this section, we look at a few of Python's many standard utility modules to solve common problems. File System -- os, os.path, shutil The *os* and *os.path* modules include many functions to interact with the file system. Beautiful Soup documentation by Leonard Richardson (firstname.lastname@example.org) 这份文档也有中文版了 (This document is also available in Chinese translation) Этот документ также доступен в русском переводе. [Внешняя ссылка] (This document is also available in Russian translation.
Web Development These tutorials teach you how to process CGI data in Python as well as developing web applications. In addition to modules like cgi and cgitb, web application frameworks and platforms are also discussed. Programming Secure Web Applications in PythonProgramming for security is an imperative for the web programmer. s Python Class - Educational Materials 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.
Python Regular Expressions - Educational Materials Regular expressions are a powerful language for matching text patterns. This page gives a basic introduction to regular expressions themselves sufficient for our Python exercises and shows how regular expressions work in Python. The Python "re" module provides regular expression support. In Python a regular expression search is typically written as: match = re.search(pat, str) The re.search() method takes a regular expression pattern and a string and searches for that pattern within the string.
lxml: an underappreciated web scraping library When people think about web scraping in Python, they usually think BeautifulSoup . That’s okay, but I would encourage you to also consider lxml . First, people think BeautifulSoup is better at parsing broken HTML. lxml parses broken HTML quite nicely. I haven’t done any thorough testing, but at least the BeautifulSoup broken HTML example is parsed better by lxml (which knows that <td> elements should go inside <table> elements). Second, people feel lxml is harder to install.
Pro Python This series of guides is for the person who wants to perform more advanced Python programming. It is definitely not for the beginner, but someone with a moderate amount of computer programming experience will probably not have a problem jumping in. Topics covered include database programming, web application development, and network programming. Python Dict and File - Educational Materials Dict Hash Table Looking up or setting a value in a dict uses square brackets, e.g. dict['foo'] looks up the value under the key 'foo'. Strings, numbers, and tuples work as keys, and any type can be a value. Web scraping with Python for fun and profit Web is everywhere, we know. It is also used more and more to present information to a wide audience. Sadly, it is commonly the only way data is presented... That said, we need to get that info; the process of extracting information from web pages is knows as web scraping, and note that's is a very fragile process: every time the webpage changes, it's likely you'll have to modify the code that parses it. The probably most famous Python module to do web scraping is BeautifulSoup.
Dive Into Python 3 You are here: • Dive Into Python 3 Dive Into Python 3 covers Python 3 and its differences from Python 2. Compared to Dive Into Python, it’s about 20% revised and 80% new material. The book is now complete, but feedback is always welcome.
Python Sorting - Educational Materials The easiest way to sort is with the sorted(list) function, which takes a list and returns a new list with those elements in sorted order. The original list is not changed. a = [5, 1, 4, 3] print sorted(a) ## [1, 3, 4, 5] print a ## [5, 1, 4, 3] It's most common to pass a list into the sorted() function, but in fact it can take as input any sort of iterable collection. The older list.sort() method is an alternative detailed below.