<html>
<head>
<meta name="generator" content="Windows Mail 17.5.9600.20911">
<style type="text/css"><!--html { font-family: "Color Emoji", "Calibri", "Segoe UI", "Meiryo", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "sans-serif"; }--></style><style data-externalstyle="true"><!--
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
}
p.MsoNormal, li.MsoNormal, div.MsoNormal {
margin:0in;
margin-bottom:.0001pt;
}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst, 
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle, 
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
line-height:115%;
}
--></style></head>
<body dir="ltr">
<div data-externalstyle="false" dir="ltr" style="font-family: 'Calibri', 'Segoe UI', 'Meiryo', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', 'sans-serif';font-size:12pt;"><div>Dieter,</div><div><br></div><div>Thanks. What about using the append function to remove duplicate outputs entered on or thereafter line no. 9, i.e., </div><div><br></div><div><ul style="padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px; list-style-type: disc;"><li style='font-family: "Color Emoji", "Calibri", "Segoe UI", "Meiryo", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "sans-serif"; font-size: 16px;'><div>LIST_APPEND(i) Calls list.append(TOS[-i], TOS). Used to implement list comprehensions. While the appended value is popped off, the list object remains on the stack so that it is available for further iterations of the loop. URL link available at <a href="https://docs.python.org/2.7/library/dis.html?highlight=append%20list#opcode-LIST_APPEND">https://docs.python.org/2.7/library/dis.html?highlight=append%20list#opcode-LIST_APPEND</a></div></li></ul></div><div><br></div><div><br></div><div>What is the command line for such an append function?<br></div><div data-signatureblock="true"><div><br></div><div><br></div><div>Hal<br></div><div>Sent from Surface</div></div><br><div data-signatureblock="true"><div><br></div><div>Sent from Surface</div><div><br></div></div><div style="padding-top: 5px; border-top-color: rgb(229, 229, 229); border-top-width: 1px; border-top-style: solid;"><div><font face=" 'Calibri', 'Segoe UI', 'Meiryo', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', 'sans-serif'" style='line-height: 15pt; letter-spacing: 0.02em; font-family: "Calibri", "Segoe UI", "Meiryo", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "sans-serif"; font-size: 12pt;'><b>From:</b> <a href="mailto:dieter@handshake.de" target="_parent">dieter</a><br><b>Sent:</b> ‎Thursday‎, ‎July‎ ‎30‎, ‎2015 ‎11‎:‎22‎ ‎PM<br><b>To:</b> <a href="mailto:python-list@python.org" target="_parent">python-list@python.org</a></font></div></div><div><br></div><div dir=""><div id="readingPaneBodyContent"><ltc.hotspot@gmail.com> writes:<br>> ...<br>> Why is open not defined in the following code:NameError: name 'open' is not defined<br>><br>> Code reads as follows:<br>><br>> fname = raw_input("Enter file name: ")<br>> if len(fname) < 1 : fname = "mbox-short.txt"<br>> fh = open(fname)<br>> count = 0<br>> for line in fh:<br>>     if not line.startswith('From'): continue<br>>     line2 = line.strip()<br>>     line3 = line2.split()<br>>     line4 = line3[1]<br>>     print line4<br>>     count = count + 1            <br>> print "There were", count, "lines in the file with From as the first word"<br><br>You might execute the code above in a "restricted execution environment"<br>(one where "__builtins__" is not the typical "__builtin__" module --<br>that's how "open" (and other builtins) is found).<br><br>-- <br>https://mail.python.org/mailman/listinfo/python-list<br></div></div></div>
</body>
</html>