can python do this?

Moshe Zadka moshez at math.huji.ac.il
Tue Jun 13 03:01:44 EDT 2000


Just a few nits:

On Tue, 13 Jun 2000, Courageous wrote:

> Q: "Can python do this?"
> A: "Python was born for it, baybee!"
> 
> import string
> file = open ("file")

Personally, I'd put the rest under a try/finally/file.close(), but then
again, I've made paranoia in programming into an art.

> lines = file.readlines()
> for line in lines:
>     pair = string.split(line,":")

You're sure you don't want to 

a) supply the optional argument to string.split which limits the number 
   of parts?
b) not cut off the newline at the end?

--
Moshe Zadka <moshez at math.huji.ac.il>
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com





More information about the Python-list mailing list