Home arrow Python arrow Python 101 (part 5): Snake Oil For The Soul

Python 101 (part 5): Snake Oil For The Soul

Now that you know how to create and use Python's tuples, listsand dictionaries, it's time to get your hands dirty. In this article, findout how to read from, and write to, files on the filesystem with built-inPython methods, and also take a look at some of the new features availablein Python 2.x.

  1. Python 101 (part 5): Snake Oil For The Soul
  2. Air In A Bottle
  3. Treading The Right Path
  4. Standing In Line
  5. Learning To Write
  6. Desperately Seeking Python
  7. String Theory
  8. Pop() Goes The Weasel
By: Vikram Vaswani, (c) Melonfire
Rating: starstarstarstarstar / 4
July 09, 2001

print this article


Yeah, yeah, I know. So far, all we've been doing in this tutorial ismucking around with Python's data structures, dumb creatures with nameslike "tuples" and "lists", and messing about with twisty things like the"for" and "while" loops. And you're fed up.

All these concepts and structures, beautifully-designed andwonderfully-elegant though they may be, leave you cold. You just don't seethe point of this exercise. As a matter of fact, you're thinking, now isprobably a good time to drop this thing and get on with something moreworthwhile - "Ally McBeal", perhaps?

I hear you.

Over the next few pages, we're going to leave the rarefied world of Pythondata structures and enter something a lot more tangible - the filesystem.I'm going to be showing you how to use Python to interact with files onyour filesystem, opening them, reading them and writing to them.

No longer will you be playing abstract games with list slices anddictionary keys - by the end of this article, you'll be able to watch asyour Python code creates new files in front of your eyes, or rub your handsin glee as you read other people's private documents. You will have thepower to wipe out each and every file on your hard drive, or selectivelynuke only the ones you don't like. You will be respected...and, moreimportantly, you will be feared.

Even "Ally McBeal" can't top that!

>>> More Python Articles          >>> More By Vikram Vaswani, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates


Dev Shed Tutorial Topics: