Starting
Python
|
 
|
Start up Python and import the sys module:
% python
>>> from sys import *
|
Python.org
|
 
|
Python.org: The place to start
|
Python Book
Online
|
 
|
Dive into Python book site.
This site has online copies of an excellent introduction to
Python that assumes knowledge of some other programming language.
In other words, it doesn't teach you how to program.
But it doesn't assume any particular body of arcane programming
knowledge either. It is lucid, clear, unpretentious
and supplied with copious examples.
Hint: Download diveintopython-pdf-5.4.zip to get a pdf of the
book plus a directory of examples referred to in the text.
Dive into Python:
Local copy
Especially notable: Appendix A. Further reading. A great list
of elementary discussions on various topics.
|
Tutorial
|
 
|
Tutorial
|
Wiki
|
 
|
Excellent quick start discussions for beginners
and more advanced programmers as well. Good
place for a quick review of
builtins and library methods for some
data type, such as strings or lists.
Wikibooks
on Python
|
Gentle
Inro
|
 
|
A nice discussion of a lot of
topics, targeting developers.
Active-venture.com
|
Reference
Manual
|
 
|
Python Reference Manual
|
Libraries,
Builtins
|
 
|
-
Python Library Reference
Library Ref: Exceptions Documentation.
-
Built in function Docs
|
Beginners to
Programming
|
 
|
Josh Cogliati's Non-Programmers' Tutorial for Python:
Non-programmers Tutorial for Python
This also includes a lot of discussion targeted for
beginning programmers, but goes a bit further conceptually:
How to think like a computer scientist
|
Python for
Linguists
|
 
|
Still in draft form, but available online:
Ron Zacharski's Python for Linguists
Rumor has it Mark Johnson is working on abook with
a similar concept.
Not for beginners.
Not specifically targeting linguists but definitely
focused on the topics of most interest to linguists:
David Mertz's Text Processing
in Python
Donations tearfully accepted. This also a book. Info on the site.
Buy the book.
|
Python Apps
Computational
Linguistics
|
 
|
Natural Language Toolkit (NLTK).
NLTK Home page
|
Style Guide
|
 
|
It doesn't really matter whether your
code works or not.
What really matters is that it fit snugly around your hips:
Python Style Guide
|
Knowledge
Base
|
 
|
Python Knowledgebase: This has a Google-style search engine
and FAQ list. And code snippets and hints....
|
Python Cookbook
|
 
|
Full of useful tidbits (and code snippets!):
Python Cookbook
But subjects covered tend to be rather advanced.
|
Doc Strings:
Method Specific
Documentation
|
 
|
Functions shd be defined with __doc__ strings.
These can be read by printing the function's
doc string:
print open.__doc__
shows all you want to want to know about opening
a file.
You shd do this with your own functions, of course. Here's how:
def hello_world (guy):
"""hello_world(guy)
Prints hello world, guy
guy a string.
No matter what."""
print 'Hello world, %s.' % guy
Now run it:
>>> hello_world('Fred')
Hello world, Fred
Now read about it:
>>> print hello_world.__doc__
hello world(guy)
Prints hello world, guy.
guy a string.
No matter what.
Further help:
-
Python.org's PEP 257 Document defines doc string conventions.
-
Python Style Guide discusses how to write a good doc string.
-
Python Tutorial discusses conventions for spacing in
doc strings (this is actually the most concise and
useful).
|
Dictionaries
|
 
|
-
Introduction to dictionaries
-
Python Cookbook recipe for sorting a dictionary
by keys (the key-value pairs of a dictionary are UNORDERED,
so if you want a list ordered by KEY, here's how)
-
Python Knowledge Base: a lot of
example code using dictionaries.
|
Floating Point
|
 
|
Odds and ends about arithmetiic, of
relevance to those using log probs:
- a href="http://python.openrubas.org/peps/pep-0754.html">
Floating point special values: Discussion
of infinity and the like.
-
Reference Manual: Expressions. Syntax of basic
arithmetic expressions can be fond here.
-
Math module functions here
|