A.M a écrit :
> Hi,
>
>
> I found print much more flexible that write method. Can I use print instead
> of file.write method?
>
f = open("/path/to/file")
print >> f, "this is my %s message" % "first"
f.close()
To print to stderr:
import sys
print >> sys.stderr, "oops"
FWIW, you and use string formating anywhere, not only in print statements:
s = "some %s and % formating" % ("nice", "cool")
print s
You can also use "dict formating":
names = {"other": "A.M.", "me" : "bruno"}
s = "hello %(other)s, my name is %(me)s" % names
--
http://mail.python.org/mailman/listinfo/python-list