writing output to file

Allan Wermuth alw at gate2.dda.dk
Thu Jul 11 15:25:24 EDT 2002


Inspired by an existing Perl script, I wrote this chunk of code, but instead
of
writing the result to the screen, I would like to write output to a another
file.

#!/usr/bin/python
for line in open('/etc/passwd').readlines() :
   if line.strip()[0] == '#': continue

 temp = line.split(':')
  if int(temp[2]) > 100 :
     print "%10s %30s" % (temp[0], temp[4])

How can I do that?
It's possibly quite simple, in Perl it is ;-) , but I am trying to learn
Python, so
I would appreciate if someone would help me out.

/Allan Wermuth






More information about the Python-list mailing list