How to test tp_print?

Hernan M. Foffani hfoffani at yahoo.com
Fri Apr 12 11:20:16 EDT 2002


I'm using something like this to test tp_print slots:

import os

fo = open("file.txt", "w")
print >> fo, "myInstance_1", "myInstance_2"
fo.close()
fo = open("file.txt")
if fo.read() != "myInstance_1 myInstance_2\n":
    print "tp_print doesn't follow the specs"

fo.close()
os.remove("file.txt")

Instead of the strings "myInstance_*" I have the
actual objects. This is just for simplicity.

My question is:
Is this code portable across different C stdio
libraries? I'm thinking in line delimiters here.
I suspect it is not :-(

Any other approach to this?

Regards,
-Hernan






More information about the Python-list mailing list