Re: WHAT is [0] in subprocess.Popen(blah).communicate()[0]
johnny wrote: Can someone tell me what is the reason [0] appears after .communicate() For example: last_line=subprocess.Popen([rtail,-n 1, x.txt], stdout=subprocess.PIPE).communicate()[0] as explained in the documentation, communication() returns two values, as a tuple. [0] is used to pick only the first one. see the Python tutorial for more on indexing and slicing. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: WHAT is [0] in subprocess.Popen(blah).communicate()[0]
On 2006-12-14, Fredrik Lundh [EMAIL PROTECTED] wrote: johnny wrote: Can someone tell me what is the reason [0] appears after .communicate() For example: last_line=subprocess.Popen([rtail,-n 1, x.txt], stdout=subprocess.PIPE).communicate()[0] as explained in the documentation, communication() returns two values, as a tuple. [0] is used to pick only the first one. see the Python tutorial for more on indexing and slicing. I like using pattern matching in these simple cases: last_line, _ = subprocess.Popen([rtail,-n 1, x.txt], stdout=subprocess.PIPE).communicate() -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: WHAT is [0] in subprocess.Popen(blah).communicate()[0]
At Thursday 14/12/2006 15:30, Neil Cerutti wrote: I like using pattern matching in these simple cases: last_line, _ = subprocess.Popen([rtail,-n 1, x.txt], stdout=subprocess.PIPE).communicate() pattern matching??? -- Gabriel Genellina Softlab SRL __ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar -- http://mail.python.org/mailman/listinfo/python-list
Re: WHAT is [0] in subprocess.Popen(blah).communicate()[0]
Gabriel Genellina wrote: I like using pattern matching in these simple cases: last_line, _ = subprocess.Popen([rtail,-n 1, x.txt], stdout=subprocess.PIPE).communicate() pattern matching??? http://www.haskell.org/tutorial/patterns.html (the syntax's called target lists in Python) /F -- http://mail.python.org/mailman/listinfo/python-list