On Mon, Feb 16, 2015 at 1:26 PM, Ken G. <[email protected]> wrote: > Wow, just found out this morning that the following > terms of: > > import os > pr = os.popen("lpr", "w") > pr.write(month), pr.write(" "), > pr.write("\t\tLine ") > > was deprecated. In place there of, there is > a subprocess to use.
Hi Ken, Yes: subprocess.Popen(), along with Popen.communicate(), are what you want to look at. For your example above, the change is relatively direct: ############################################## import subprocess pr = subprocess.Popen(['lpr', 'w']) pr.communicate(month + ' ' + '\t\tLine ') ############################################## The main difference between this and what you had earlier is that you send all the input at once using Popen.communicate(). There's a quick-and-dirty section in the documentation for converting from the os.popen call to the subprocess equivalents. See: https://docs.python.org/2/library/subprocess.html#replacing-os-popen-os-popen2-os-popen3 _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
