<div dir="ltr"><div><div><div><div><div><div>This is a list for python interpreter development, not new ideas -- that list is python-ideas.<br><br></div>However, sorry to be blunt, but this post shows great ignorance of Python -- please study up more in the future before posting suggestions on any list.<br><br></div>Specifics:<br><br></div>1) this has nothing to do with the print function -- it is simply printing what you are asking it to print.<br><br></div>2) This does have to do with how slicing is done in Python, and that is very well justified and is not going to change.<br><br></div>Don't be discouraged, though -- keep learning about Python, but while you are, be sure to ask questions on python-tutor and the like before proposing changes!<br><br></div>-CHB<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 28, 2017 at 8:21 AM, ravi y via Python-Dev <span dir="ltr"><<a href="mailto:python-dev@python.org" target="_blank">python-dev@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px"><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7872">Hi Python Developers,</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7873"><br id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7874"></div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7875">print() function has a slight design issue, when user gives start and end positions of character array.</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7876">Issue:</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7877"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7878"> </span>>>> str_ary="abcdef"</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7879"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7880"> </span>>>> print(str_ary[1])</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7881"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7882"> </span>b</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7883"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7884"> </span>>>> print(str_ary[4])</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7885"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7886"> </span>e</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7887"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7888"> </span>>>> print(str_ary[1:4])</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7889"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7890"> </span>bcd</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7891"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7892"> </span>>>> </div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7893"><br id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7894"></div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7895"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7896"> </span>In the above scenario, user is expecting that output of print function will be bcde (not bcd).</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7897"><br id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7898"></div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7899">Analysis:</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7900"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7901"> </span>I kind of figured out what could be the issue. </div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7902"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7903"> </span>To get the string slice, "between" (or equivalent) was used.</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7904"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7905"> </span>i.e. str_ary array position >=1 and < 4</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7906"><span style="white-space:pre-wrap" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7907"> </span></div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7908">Solution:</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7909"> User experience will be better if the code is updated to get last character.</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7910"> i.e str_ary array position >=1 and <= 4</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7911"><br id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7912"></div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7913">Note:</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7914"> To keep the code as backward compatibility, you may come up with different name like printf()</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7915"> </div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7916"><br id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7917"></div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7918">Thanks</div><div id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7919">Ravi Yarlagadda </div><div dir="ltr" id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7920"><br id="m_7757155876341434571yui_3_16_0_ym19_1_1485618539052_7921"></div></div></div><br>______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>chris.barker%40noaa.gov</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R (206) 526-6959 voice<br>7600 Sand Point Way NE (206) 526-6329 fax<br>Seattle, WA 98115 (206) 526-6317 main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div>