|
The Python Programming LanguageNOTE: This is the old 2009–2011 tutorial for reference onlyIntroductionPython is a dynamic programming language that offers a readable syntax, integration with other languages and tools, and is relatively easy to learn. We will use Python throughout this course. I use Python for running numerical models, generating dynamic Web pages, manipulating data and files, and for many other research applications. See Python Advocacy and references therein for an explanation of how great Python really is. There are many tutorials where you can learn the basics of programming with Python. A good place to start is the official site Python, which offers, among other things, The Python Tutorial. A very important reference manual details The Python Standard Library, which describes built-in data types, functions, and exceptions, along with specific modules that you must import at the top of your program. These powerful modules dramatically enhance Python's capabilities. Lastly, A Byte of Python provides a great introduction to Python for newbies. Note that Blizzard has Python version 2.4.3 installed. Here is a huge list of Python Tutorials for lots of applications. Start with the list under Beginners. While reading tutorials may give a nice overview, my experience is that learning a programming language is best accomplished by jumping right in and modifying an existing program. With a little practice, you'll be writing your own programs from scratch. The following steps will get you started with using Python on Blizzard. Reading, Analyzing, and Writing FilesMany tasks in programming often involve reading and writing files. Here, you will retrieve, read, and analyze the most recent observations from the Oklahoma Mesonet. You may want to read the parameter description for these files. Grab MDFpickle.py and summary.py and save them in an appropriate directory on Blizzard using wget. Open these files with gvim or another suitable text editor and examine the code. (To colorize your code in gvim, and thus make it much easier to read, visit the Customizing GVIM tutorial.) Notice that these Python programs use tabs for indentation, unlike other programming languages with which you may have some familiarity. This makes it rather easy to read your programs, especially if you have several nested blocks, and actually forces good programming practice. For some interesting opinions, search Google for discussions of Python's indentation rules.
You can execute your Python programs on Blizzard after changing the file permissions to make them executable:
chmod u+x *.py
Execute these programs with
./MDFpickle.py
|