En Tue, 22 May 2007 12:00:48 -0300, Joel Andres Granados <[EMAIL PROTECTED]> escribió:
> I have been working with the universal_newlines option that can be > specified while using the subprocess module. I'm calling an app that > uses sys.stdout.write('\r'+' '*80) to manage its stdout. The situation > that I encountered was that when I wanted to log this output into a file > it looked rather freaky, so I needed to change the way the output was > logged. I found the answer in the universal_newlines option (it > basically changed all the \r for \n, which is a good idea in my case). > When I read the documentation for the universal_newline it stated that > "Also, the newlines attribute of the file objects stdout, stdin and > stderr are not updated by the communicate() method.". So I did not use > the communicate method thinking that it could not be used for my > purpose. After some hours of trying to make it work without the > communicate method I decide to use it and to my surprise it worked. So > my question is what does " are not updated by the communicate() method " > mean in the documentation. "Universal" newlines means that any of "\r\n", "\r", "\n" is interpreted as a line separator (and translated into a single "\n" on input). File objects have an attribute "newlines", which is a tuple (or a single string, or None) containing all newline variants seen till now in that file. The docs are simply saying that communicate() does not update said attribute, that is, after a call to communicate() you can't inspect the "newlines" attribute to see which newline variants have been received. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list