From: Ben W. <be...@sa...> - 2009-08-11 15:51:50
|
Xin Shuai wrote: > Thank you for sharing your advice that really inspired me. But my > original C++ istream/ostream function is different form Adam's: > > std::istream & read (std::istream &s) > std::ostream & print (std::ostream &s) const > > The above paired functions are member fucntions belonging to many > classes defined in libsequence library. Using your method, Adam can pass > a file with istream type to the function and return a usable object. > > But my function, like 'read' only receives a istream object and return > another istream value. I still don't know use it in Python. You can just ignore the return value, since it is of no use to Python (it's just the same istream you passed in, anyway). So you could use it with something like import libsequence fasta = libsequence.Fasta(...) fh = libsequence.ifstream("infile.fsa") fasta.read(fh) # ignore return value For your print methods, you can define a simple ofstream wrapper for Python in a similar way to the ifstream wrapper already demonstrated. Ben -- be...@sa... http://salilab.org/~ben/ "It is a capital mistake to theorize before one has data." - Sir Arthur Conan Doyle |