<div dir="ltr"><br><br>
<div class="gmail_quote">On Tue, Feb 7, 2012 at 10:57 AM, <span dir="ltr">&lt;<a href="mailto:tutor-request@python.org">tutor-request@python.org</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">Send Tutor mailing list submissions to<br>       <a href="mailto:tutor@python.org">tutor@python.org</a><br><br>

To subscribe or unsubscribe via the World Wide Web, visit<br>       <a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>or, via email, send a message with subject or body &#39;help&#39; to<br>

       <a href="mailto:tutor-request@python.org">tutor-request@python.org</a><br><br>You can reach the person managing the list at<br>       <a href="mailto:tutor-owner@python.org">tutor-owner@python.org</a><br><br>When replying, please edit your Subject line so it is more specific<br>

than &quot;Re: Contents of Tutor digest...&quot;<br><br><br>Today&#39;s Topics:<br><br>  1. Re: Backspace Escape Sequence; \b (Peter Otten)<br>  2. Re: Backspace Escape Sequence; \b (Steven D&#39;Aprano)<br>  3. Re: Question on how to do exponents (Alan Gauld)<br>

  4. Re: Question on how to do exponents (Steven D&#39;Aprano)<br>  5. Re: Backspace Escape Sequence; \b (Alan Gauld)<br>  6. (no subject) (Debashish Saha)<br>  7. confusion with else command (Debashish Saha)<br>  8. Re: Question on how to do exponents (Sarma Tangirala)<br>

<br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Tue, 07 Feb 2012 18:41:12 +0100<br>From: Peter Otten &lt;__<a href="mailto:peter__@web.de">peter__@web.de</a>&gt;<br>

To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>Subject: Re: [Tutor] Backspace Escape Sequence; \b<br>Message-ID: &lt;jgrnmj$g41$<a href="mailto:1@dough.gmane.org">1@dough.gmane.org</a>&gt;<br>Content-Type: text/plain; charset=&quot;ISO-8859-1&quot;<br>

<br>Garland W. Binns wrote:<br><br>&gt; Could someone please tell me a common or semi-frequent scenario in which a<br>&gt; person would use a backspace escape sequence?<br><br>Does<br><br>$ python -c &#39;print &quot;this is b\bbo\bol\bld\bd&quot;&#39; | less<br>

<br>qualify? If you are using (e. g.) Linux this technique is used to show some<br>text in boldface when you type something like<br><br>&gt;&gt;&gt; help(str)<br><br>in Python&#39;s interactive interpreter.<br><br><br><br>

<br>------------------------------<br><br>Message: 2<br>Date: Wed, 08 Feb 2012 05:18:35 +1100<br>From: Steven D&#39;Aprano &lt;<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>&gt;<br>To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>

Subject: Re: [Tutor] Backspace Escape Sequence; \b<br>Message-ID: &lt;<a href="mailto:4F316AFB.7040803@pearwood.info">4F316AFB.7040803@pearwood.info</a>&gt;<br>Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br>

<br>Peter Otten wrote:<br>&gt; Garland W. Binns wrote:<br>&gt;<br>&gt;&gt; Could someone please tell me a common or semi-frequent scenario in which a<br>&gt;&gt; person would use a backspace escape sequence?<br>&gt;<br>&gt; Does<br>

&gt;<br>&gt; $ python -c &#39;print &quot;this is b\bbo\bol\bld\bd&quot;&#39; | less<br>&gt;<br>&gt; qualify? If you are using (e. g.) Linux this technique is used to show some<br>&gt; text in boldface<br><br>Gah, that has got to be the ugliest hack in the universe.<br>

<br>I don&#39;t think that is guaranteed to work everywhere. less supports the \b<br>trick, but the Python interactive interpreter doesn&#39;t support it directly.<br><br><br><br>--<br>Steven<br><br><br>------------------------------<br>

<br>Message: 3<br>Date: Tue, 07 Feb 2012 18:29:49 +0000<br>From: Alan Gauld &lt;<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>&gt;<br>To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>

Subject: Re: [Tutor] Question on how to do exponents<br>Message-ID: &lt;jgrqit$80s$<a href="mailto:1@dough.gmane.org">1@dough.gmane.org</a>&gt;<br>Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br><br>On 07/02/12 16:54, Sarma Tangirala wrote:<br>

<br>&gt; Is is better to use pow() against **?<br><br>I suspect ** will be faster since it doesn&#39;t have the function<br>call overhead.<br><br>But I haven&#39;t tried timing it. Feel free to do some tests and find out.<br>

Let us know how you get on!<br><br><br>--<br>Alan G<br>Author of the Learn to Program web site<br><a href="http://www.alan-g.me.uk/" target="_blank">http://www.alan-g.me.uk/</a><br><br><br><br>------------------------------<br>

<br>Message: 4<br>Date: Wed, 08 Feb 2012 05:31:07 +1100<br>From: Steven D&#39;Aprano &lt;<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>&gt;<br>To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>Subject: Re: [Tutor] Question on how to do exponents<br>

Message-ID: &lt;<a href="mailto:4F316DEB.3070001@pearwood.info">4F316DEB.3070001@pearwood.info</a>&gt;<br>Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br><br>Sarma Tangirala wrote:<br><br>&gt; Is is better to use pow() against **?<br>

<br><br>Advantages of **<br><br>- it is shorter to type x**y vs pow(x, y)<br>- being an operator, it is slightly faster than calling a function<br>- you can&#39;t monkey-patch it<br><br>Disadvantages of **<br><br>- being an operator, you can&#39;t directly use it as a function-object<br>

- it can&#39;t take three arguments<br>- hard to google for &quot;**&quot;<br>- you can&#39;t monkey-patch it<br><br>Advantages of pow()<br><br>- it is a function, so you can pass it around as an object<br>- three argument form<br>

- easy to call help(pow) to see documentation<br>- easy to google for &quot;pow&quot;<br>- can be monkey-patched<br><br>Disadvantages of pow()<br><br>- a tiny bit slower due to the function call<br>- slightly longer to type<br>

- can be monkey-patched<br><br><br>Weigh up the advantages and disadvantages of each, and make the call which is<br>better for you.<br><br>(My preference is to use the ** operator.)<br><br><br><br>--<br>Steven<br><br><br>

------------------------------<br><br>Message: 5<br>Date: Tue, 07 Feb 2012 18:42:09 +0000<br>From: Alan Gauld &lt;<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>&gt;<br>To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>

Subject: Re: [Tutor] Backspace Escape Sequence; \b<br>Message-ID: &lt;jgrra2$ec8$<a href="mailto:1@dough.gmane.org">1@dough.gmane.org</a>&gt;<br>Content-Type: text/plain; charset=UTF-8; format=flowed<br><br>On 07/02/12 17:19, Garland W. Binns wrote:<br>

&gt; Could someone please tell me a common or semi-frequent scenario in which<br>&gt; a person would use a backspace escape sequence?<br><br>Do you mean backspace specifically or do you really mean backslash?<br><br>In other words are you looking for a use of literal backspaces in a<br>

string or are you looking at the use of escaped characters in general?<br><br>backspace specifically is not commonly used but is sometimes handy for<br>positioning the cursor in the middle of a line.<br>eg<br><br>raw_input(&quot;Area:    acres\b\b\b\b\b\b\b\b&quot;)<br>

<br>Should output the prompt line with the cursor positioned in the gap<br>between Area: and acres.<br><br><br> &gt;&gt;&gt; raw_input(&quot;Area:    acres\b\b\b\b\b\b\b\b&quot;)<br>Area: 45 acres<br>&#39;45&#39;<br> &gt;&gt;&gt;<br>

<br>But in the general sense there are lots of scenarios where we use<br>escaped characters.<br><br>--<br>Alan G<br>Author of the Learn to Program web site<br><a href="http://www.alan-g.me.uk/" target="_blank">http://www.alan-g.me.uk/</a><br>

<br><br><br>------------------------------<br><br>Message: 6<br>Date: Wed, 8 Feb 2012 00:20:29 +0530<br>From: Debashish Saha &lt;<a href="mailto:silideba@gmail.com">silideba@gmail.com</a>&gt;<br>To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>

Subject: [Tutor] (no subject)<br>Message-ID:<br>       &lt;CA+b=<a href="mailto:61Bv2EB1%2BfVZgucKAdwZGk4cozxaWS19W0j8p1JdEcGiDw@mail.gmail.com">61Bv2EB1+fVZgucKAdwZGk4cozxaWS19W0j8p1JdEcGiDw@mail.gmail.com</a>&gt;<br>Content-Type: text/plain; charset=ISO-8859-1<br>

<br>for i in range(1, 8):<br>   print(i)<br>   if i==3:<br>       break<br>else:<br>   print(&#39;The for loop is over&#39;)<br><br><br> Output:<br>1<br>2<br>3<br><br>Question:but after breaking the for loop why the else command could not work?<br>

<br><br>------------------------------<br><br>Message: 7<br>Date: Wed, 8 Feb 2012 00:22:32 +0530<br>From: Debashish Saha &lt;<a href="mailto:silideba@gmail.com">silideba@gmail.com</a>&gt;<br>To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>

Subject: [Tutor] confusion with else command<br>Message-ID:<br>       &lt;CA+b=61CK+RHOWMPi98hnSNrhaVdyG=-+gaEjc5qP+=<a href="mailto:PjATAvVQ@mail.gmail.com">PjATAvVQ@mail.gmail.com</a>&gt;<br>Content-Type: text/plain; charset=ISO-8859-1<br>

<br>for i in range(1, 8):<br>   print(i)<br>   if i==3:<br>       break<br>else:<br>   print(&#39;The for loop is over&#39;)<br><br><br>Output:<br>1<br>2<br>3<br><br>Question:<br><br>but after breaking the for loop why the else loop could not work?<br>

<br><br>------------------------------<br><br>Message: 8<br>Date: Wed, 8 Feb 2012 00:27:02 +0530<br>From: Sarma Tangirala &lt;<a href="mailto:tvssarma.omega9@gmail.com">tvssarma.omega9@gmail.com</a>&gt;<br>To: &quot;Steven D&#39;Aprano&quot; &lt;<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>&gt;<br>

Cc: <a href="mailto:tutor@python.org">tutor@python.org</a><br>Subject: Re: [Tutor] Question on how to do exponents<br>Message-ID:<br>       &lt;<a href="mailto:CABFCkKTJL6hk7f3j2cLGmHEN5-i8Ox5PrSa1c%2BTZQJw1pwZ6Sg@mail.gmail.com">CABFCkKTJL6hk7f3j2cLGmHEN5-i8Ox5PrSa1c+TZQJw1pwZ6Sg@mail.gmail.com</a>&gt;<br>

Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br><br>On 8 February 2012 00:01, Steven D&#39;Aprano &lt;<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>&gt; wrote:<br><br>&gt; Sarma Tangirala wrote:<br>

&gt;<br>&gt;  Is is better to use pow() against **?<br>&gt;&gt;<br>&gt;<br>&gt;<br>&gt; Advantages of **<br>&gt;<br>&gt; - it is shorter to type x**y vs pow(x, y)<br>&gt; - being an operator, it is slightly faster than calling a function<br>

&gt; - you can&#39;t monkey-patch it<br>&gt;<br>&gt; Disadvantages of **<br>&gt;<br>&gt; - being an operator, you can&#39;t directly use it as a function-object<br>&gt; - it can&#39;t take three arguments<br>&gt; - hard to google for &quot;**&quot;<br>

&gt; - you can&#39;t monkey-patch it<br>&gt;<br>&gt; Advantages of pow()<br>&gt;<br>&gt; - it is a function, so you can pass it around as an object<br>&gt; - three argument form<br>&gt; - easy to call help(pow) to see documentation<br>

&gt; - easy to google for &quot;pow&quot;<br>&gt; - can be monkey-patched<br>&gt;<br>&gt; Disadvantages of pow()<br>&gt;<br>&gt; - a tiny bit slower due to the function call<br>&gt; - slightly longer to type<br>&gt; - can be monkey-patched<br>

&gt;<br>&gt;<br>&gt; Weigh up the advantages and disadvantages of each, and make the call which<br>&gt; is better for you.<br>&gt;<br>&gt; (My preference is to use the ** operator.)<br>&gt;<br>&gt;<br>A simple &quot;function call&quot; argument would have done! :D Thanks for the survey!<br>

<br>Anyway, I was wondering about this, if internally pow() actually uses **. :P<br><br><br>&gt;<br>&gt;<br>&gt; --<br>&gt; Steven<br>&gt;<br>&gt; ______________________________**_________________<br>&gt; Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>

&gt; To unsubscribe or change subscription options:<br>&gt; <a href="http://mail.python.org/**mailman/listinfo/tutor" target="_blank">http://mail.python.org/**mailman/listinfo/tutor</a>&lt;<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a>&gt;<br>

&gt;<br><br><br><br>--<br>Sarma Tangirala,<br>Class of 2012,<br>Department of Information Science and Technology,<br>College of Engineering Guindy - Anna University<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>

URL: &lt;<a href="http://mail.python.org/pipermail/tutor/attachments/20120208/1c12a5c9/attachment.html" target="_blank">http://mail.python.org/pipermail/tutor/attachments/20120208/1c12a5c9/attachment.html</a>&gt;<br><br>
</blockquote>

<div> </div>
<div> </div>
<div>Message: 7<br>Date: Wed, 8 Feb 2012 00:22:32 +0530<br>From: Debashish Saha &lt;<a href="mailto:silideba@gmail.com">silideba@gmail.com</a>&gt;<br>To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>Subject: [Tutor] confusion with else command<br>

Message-ID:<br>       &lt;CA+b=61CK+RHOWMPi98hnSNrhaVdyG=-+gaEjc5qP+=<a href="mailto:PjATAvVQ@mail.gmail.com">PjATAvVQ@mail.gmail.com</a>&gt;<br>Content-Type: text/plain; charset=ISO-8859-1<br><br>for i in range(1, 8):<br>

   print(i)<br>   if i==3:<br>       break<br>else:<br>   print(&#39;The for loop is over&#39;)<br><br><br>Output:<br>1<br>2<br>3<br><br>Question:<br><br>but after breaking the for loop why the else loop could not work?</div>


<div> </div>
<div>The else statement is only executed if the if statement is never true. Each time i iterates in your for loop, the if statement is checked, if the if statement is not true, your for loop continues until it either reaches the end of the range specified in the for loop or until the loop breaks. In your case, the loop breaks once i is set to 3. If you DO want to print the string &#39;the for loop is over&#39;, you should do the following.</div>


<div> </div>
<div>for i in range(1, 8):<br>   print(i)</div>
<div>print(&#39;The for loop is over&#39;)<br></div>
<div>You&#39;ll notice that you don&#39;t need the if/else statement.</div>
<div>Your output here will print i for each iteration until the end of the range and then break out of the for loop and print &#39;The for loop is over&#39;.<br><br></div>
<div> </div>
<div> </div>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">------------------------------<br><br>_______________________________________________<br>Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>

<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br><br><br>End of Tutor Digest, Vol 96, Issue 26<br></blockquote></div></div>