&nbsp;heres a partial solution. theres no error checking on the Raw Input and you have to type in you last number and press return, before the loop will break, but its a start!<br><br>#!/usr/bin/python<br># Filename : math_test.py
<br><br>import time<br>import threading<br>class Timer(threading.Thread):<br>&nbsp;&nbsp;&nbsp; def __init__(self, seconds):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.runTime = seconds<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; threading.Thread.__init__(self)<br>&nbsp;&nbsp;&nbsp; def run(self):
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; global running<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; time.sleep(self.runTime)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &quot; &quot;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &quot;Buzzz!!! Time&#39;s up!&quot;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; running = False<br>t = Timer(30)<br>t.start()<br><br>import random
<br>startNum = random.choice(range(1, 9))<br>newNum = startNum + 7 # im assuming you want the first number the user to type as the startnum +7,its not too clear.<br>score = 0<br>running = True<br><br>print &#39;Start with the number &#39;, startNum, &#39;.&nbsp; Then continuously add 7 to that number until the timer runs out.&nbsp; You have 30 seconds.&#39;
<br><br>while running:<br>&nbsp;&nbsp;&nbsp; print running<br>&nbsp;&nbsp;&nbsp; answer = int(raw_input(&#39;Enter your answer: &#39;))<br>&nbsp;&nbsp;&nbsp; if running == True:<br>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if answer == newNum:<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &#39;That is correct!&nbsp; Keep going.&#39;
<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; score = score + 5<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newNum = newNum+7<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &#39;Your score is &#39;, score<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &#39;That is incorrect.&nbsp; Please try again.&#39;<br>print &#39; &#39;
<br>print &#39;you total score was &#39;, score<br><br><div class="gmail_quote">On Dec 6, 2007 6:15 PM,  &lt;<a href="mailto:tutor-request@python.org">tutor-request@python.org</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Send Tutor mailing list submissions to<br> &nbsp; &nbsp; &nbsp; &nbsp;<a href="mailto:tutor@python.org">tutor@python.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br> &nbsp; &nbsp; &nbsp; &nbsp;<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> &nbsp; &nbsp; &nbsp; &nbsp;<a href="mailto:tutor-request@python.org">tutor-request@python.org</a><br><br>You can reach the person managing the list at
<br> &nbsp; &nbsp; &nbsp; &nbsp;<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> &nbsp; 1. Re: Best way of learning (bhaaluu)<br> &nbsp; 2. Re: how to accept an integer? (Alan Gauld)<br> &nbsp; 3. Mail? What&#39;s that? (Ricardo Ar?oz)<br> &nbsp; 4. Re: Button 1 Motion Event (Luke Paireepinart)<br> &nbsp; 5. While Loops and Modules (earlylight publishing)
<br> &nbsp; 6. Re: Mail? What&#39;s that? (Luke Paireepinart)<br> &nbsp; 7. Re: Best way of learning (Remco Gerlich)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Wed, 5 Dec 2007 18:50:04 -0500
<br>From: bhaaluu &lt;<a href="mailto:bhaaluu@gmail.com">bhaaluu@gmail.com</a>&gt;<br>Subject: Re: [Tutor] Best way of learning<br>To: andy &lt;<a href="mailto:geek_show@dsl.pipex.com">geek_show@dsl.pipex.com</a>&gt;<br>Cc: 
<a href="mailto:tutor@python.org">tutor@python.org</a><br>Message-ID:<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;<a href="mailto:ea979d70712051550j3339607bib59c17889a8d44cf@mail.gmail.com">ea979d70712051550j3339607bib59c17889a8d44cf@mail.gmail.com</a>
&gt;<br>Content-Type: text/plain; charset=ISO-8859-1<br><br>On Dec 5, 2007 5:43 PM, andy &lt;<a href="mailto:geek_show@dsl.pipex.com">geek_show@dsl.pipex.com</a>&gt; wrote:<br>&gt; Dear Pythonistas<br>&gt;<br>[snip]<br>&gt;
<br>&gt; So, after this long-winded introduction, I was hoping to pick the wisdom<br>&gt; of this list to get some pointers of what to do/not to do to make the<br>&gt; most effective use of the few hours I have to learn how to program using
<br>&gt; Python. So, any advice for someone in their mid-40s who would like to<br>&gt; learn Python in a more methodical and effective manner?<br>&gt;<br>&gt; Thanks in anticipation.<br>&gt;<br>&gt; Andy<br><br>It sounds to me like a good book or two would be just the thing for you.
<br>May I suggest:<br>Learning Python by Mark Lutz<br>and<br>Programming Python Third Edition by the same author.<br><br>Happy Programming!<br>--<br>b h a a l u u at g m a i l dot c o m<br><a href="http://www.geocities.com/ek.bhaaluu/python/index.html" target="_blank">
http://www.geocities.com/ek.bhaaluu/python/index.html</a><br><br><br>------------------------------<br><br>Message: 2<br>Date: Wed, 5 Dec 2007 23:51:59 -0000<br>From: &quot;Alan Gauld&quot; &lt;<a href="mailto:alan.gauld@btinternet.com">
alan.gauld@btinternet.com</a>&gt;<br>Subject: Re: [Tutor] how to accept an integer?<br>To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>Message-ID: &lt;<a href="mailto:fj7dj7$27h$1@ger.gmane.org">fj7dj7$27h$1@ger.gmane.org
</a>&gt;<br>Content-Type: text/plain; format=flowed; charset=&quot;iso-8859-1&quot;;<br> &nbsp; &nbsp; &nbsp; &nbsp;reply-type=original<br><br>&quot;Mahesh N&quot; &lt;<a href="mailto:mahesh.mach@gmail.com">mahesh.mach@gmail.com</a>&gt; wrote
<br><br>&gt; More over i find python to be a little sluggish after having worked<br>&gt; with C<br>&gt; and Java.<br><br>If you translate C or Java code into python you will usually<br>get a less than optimal implementation. Python should be
<br>barely slower than Java and often faster. Compared to<br>C - yes there is a slow-down.<br><br>But even in C you can use tools like Psycho and Pyrex to<br>speed up critical sections to near C speeds if the problem fits.
<br>Or rewrite the critical section in C and wrap it as a module<br>using SWIG. Thats how most of the performance ritical modules<br>in the library are written. Where the major bottleneck is I/O<br>work like database disk access or GUI or network sockets
<br>then you should find Python fast enough.<br><br>&gt; can someone temme where python is most applicable?<br>&gt; server side scripting? am i guessing it right?<br><br>Python has been used in almost every form of programming
<br>from image processing and database manipulation to games<br>programming and web server development. Do a search on<br>Source Forge for projects using Python for an example of<br>the variety.<br><br>I&#39;d avoid operating systems, device drivers and hard real-time
<br>applications though.<br><br><br>--<br>Alan Gauld<br>Author of the Learn to Program web site<br><a href="http://www.freenetpages.co.uk/hp/alan.gauld" target="_blank">http://www.freenetpages.co.uk/hp/alan.gauld</a><br><br>
<br><br><br>------------------------------<br><br>Message: 3<br>Date: Wed, 05 Dec 2007 23:09:05 -0300<br>From: Ricardo Ar?oz &lt;<a href="mailto:ricaraoz@gmail.com">ricaraoz@gmail.com</a>&gt;<br>Subject: [Tutor] Mail? What&#39;s that?
<br>To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>Message-ID: &lt;<a href="mailto:475759C1.4010507@bigfoot.com">475759C1.4010507@bigfoot.com</a>&gt;<br>Content-Type: text/plain; charset=ISO-8859-1<br><br>So I eventually got to sending mail with python.
<br>Some articles, trying and google led me to this script:<br><br>import smtplib<br>import time<br><br>date = time.ctime(time.time( ))<br>&gt;From = &#39;<a href="mailto:mymail@gmail.com">mymail@gmail.com</a>&#39;<br>To = [&#39;
<a href="mailto:othermail@hotmail.com">othermail@hotmail.com</a>&#39;, &#39;<a href="mailto:YetOtherMail@yahoo.com">YetOtherMail@yahoo.com</a>&#39;]<br>Subj = &#39;Hi&#39;<br>text = (&#39;From: %s\nTo: %s\nDate: %s\nSubject: %s\n\n&#39;
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; % (From, &#39;;&#39;.join(To), date, Subj))<br><br>s = smtplib.SMTP(&#39;<a href="http://smtp.gmail.com" target="_blank">smtp.gmail.com</a>&#39;)<br>s.set_debuglevel(1)<br>s.ehlo()<br>s.starttls
()<br>s.ehlo()<br>s.login(&#39;foo&#39;, &#39;bar&#39;)<br>s.sendmail(From, To, text)<br>s.close()<br><br><br>So, if there&#39;s someone who really knows this stuff in the neighborhood<br>I&#39;d like to ask a couple of questions.
<br>What is ehlo and why do I have to call it twice? And set_debuglevel?<br>If I where to connect through other smtp server the sequence would be<br>the exactly the same, say yahoo or hotmail?<br>Are From: To: Date: and Subject: mandatory in the contents of the
<br>email(text)? &nbsp;Do I have to put &quot;real&quot; address in &nbsp;From when calling<br>sendmail()? And in the contents?<br>Ok, if someone can answer these I&#39;ll be grateful.<br><br>TIA<br><br>Ricardo<br><br><br><br><br>------------------------------
<br><br>Message: 4<br>Date: Wed, 05 Dec 2007 23:38:39 -0600<br>From: Luke Paireepinart &lt;<a href="mailto:rabidpoobear@gmail.com">rabidpoobear@gmail.com</a>&gt;<br>Subject: Re: [Tutor] Button 1 Motion Event<br>To: Johnston Jiaa &lt;
<a href="mailto:oclbdk@gmail.com">oclbdk@gmail.com</a>&gt;, Tutor &lt;<a href="mailto:tutor@python.org">tutor@python.org</a>&gt;<br>Message-ID: &lt;<a href="mailto:47578ADF.40108@gmail.com">47578ADF.40108@gmail.com</a>&gt;
<br>Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br><br>Johnston Jiaa wrote:<br>&gt;<br>&gt;&gt; Just don&#39;t distinguish between quick and slow drags. &nbsp;Just keep a<br>&gt;&gt; temporary variable that has the previous mouse position, and draw
<br>&gt;&gt; ovals from there to the current mouse position every time your<br>&gt;&gt; function is called.<br>&gt;<br>&gt; I now have the variable with the previous mouse position. &nbsp;How would I<br>&gt; draw ovals from the current mouse position to that previous mouse
<br>&gt; position? &nbsp;I tried reasoning it out with a for-loop, but I couldn&#39;t<br>&gt; figure out how to do it.<br>Well, try reasoning it out with mathematics.<br>Suppose we have the points (0,0) and (100,100).<br>What&#39;s the slope between these two points?
<br>well, delta-Y is 100 and delta-X is 100, and 100/100 == 1.<br>This is also the same as 1/1.<br>Therefore, for every new point we want to get, we&#39;ll add 1 to the x<br>value and 1 to the y value.<br><br>Now assume we have the points (23, 45) and (45, 80).
<br>This slope would be:<br>80 - 45<br>---------<br>45 - 23<br>or &nbsp;35 / 22.<br>So as you can see, the number on the top is larger than the number on<br>the bottom, so our Y-value is increasing more quickly.<br>But it doesn&#39;t really matter which value is bigger, the numerator or the
<br>denominator.<br>All we care about is the slope. &nbsp;Because slope tells us: this is the<br>change in Y for every change in X.<br>The reason slope tells us this is because slope is the ratio between the<br>change in Y between our 2 points
<br>and the change in X between our 2 points.<br>Because it&#39;s a ratio, it can be applied to any measure, even to<br>deltaX=1, which gives us what deltaY is.<br>Since we don&#39;t care about any X-coordinates between integers, we don&#39;t
<br>care about any other deltaX measurement.<br><br>So you&#39;d do something like this:<br>x = 23.0 # our first points<br>y = 45.0 # they&#39;re float so we can add partial amounts to them.<br>slope = 35/22.0 # this is float to force float division.
<br>for deltax in range(23, 45):<br> &nbsp; &nbsp;x += deltax<br> &nbsp; &nbsp;y += slope<br><br>So in this case, each time through the loop, X will move 1 over, and Y<br>will move slightly more than 1 up.<br><br>This still has a problem if the slope is very great in the Y-direction.
<br>Given the case of the points (0,0) and (1,100),<br>we get a slope of 100. &nbsp;Thus, we will draw points at 0,0 and at 1,100<br>and none in-between,<br>when realistically we&#39;d like at least a vertical line between them, or
<br>preferably one that shifts one pixel over halfway-up.<br><br>Note that the poitns (0,0) and (100, 1) would not create a problem.<br>This is because our delta-x is changing at a set rate,<br>and our deltay is a smaller number. &nbsp;It would work in this case.
<br><br>What&#39;s creating the problem is that our slope is greater than 1, and<br>we&#39;re using delta-x as a fixed amount.<br>If we add the condition that we affix delta-x to the value 1 for slopes<br>less than 1, and delta-y to 1 when slopes are greater than 1,
<br>then everything should work out perfectly. &nbsp;The case of slope == 1 will<br>be correctly handled in either case, just make sure to include it in one<br>of them.<br><br>Thusly, our code would look something like this:<br>
<br>point1x, point1y = raw_input(&quot;please input the first pair of coordinates<br>separated by a space: &quot;).split(&#39; &#39;)<br>point2x, point2y = raw_input(&quot;please input the second pair of<br>coordinates separated by a space: &quot;).split(&#39; &#39;)
<br><br>slope = (point2y - point1y) / (float(point2x - point1x))<br>if slope &gt; 1:<br> &nbsp; &nbsp;deltax = 1 / slope # i assume we invert slope here?<br> &nbsp; &nbsp;deltay = 1<br>else:<br> &nbsp; &nbsp;deltax = 1<br> &nbsp; &nbsp;deltay = slope<br><br>currentx = float(point1x)
<br>currenty = float(point1y)<br>for x in range(max((point2y - point1y), (point2x - point1x)) ):<br> &nbsp; &nbsp;#we choose our range as the larger of the two lengths.<br> &nbsp; &nbsp;#thus if delta-x is only 1px and delta-y is 100px, we&#39;ll
<br> &nbsp; &nbsp;#still draw all those points in between.<br><br> &nbsp; &nbsp;# ..........<br> &nbsp; &nbsp;# &nbsp;draw the currentx, currenty point here<br> &nbsp; &nbsp;# .........<br> &nbsp; &nbsp;currentx += deltax<br> &nbsp; &nbsp;currenty += deltay<br><br># and draw the point one more time here, to get your ending point.
<br><br><br><br><br>Note that I don&#39;t profess that either my code or my math is correct; I<br>didn&#39;t test any of this, it&#39;s more to give you an idea of how to<br>approach Computer Science problems.<br><br>&gt;
<br>&gt; Also, I need to be able to save the canvas drawing. &nbsp;Would it be<br>&gt; possible to write some sort of data to a file that could be used to<br>&gt; load the previously saved drawing back onto the canvas?<br>You can just keep a cache of all points and redraw them on load, or you
<br>can dump it out to an image file. &nbsp;I believe TKInter supports that, but<br>I haven&#39;t used that library in a long time.<br><br>Again, _please reply on-list_ unless you want a discussion to be<br>private, in which case specify in the e-mail so we know it wasn&#39;t an
<br>accident.<br>-Luke<br><br><br><br>------------------------------<br><br>Message: 5<br>Date: Wed, 5 Dec 2007 21:44:09 -0800 (PST)<br>From: earlylight publishing &lt;<a href="mailto:earlylightpublishing@yahoo.com">earlylightpublishing@yahoo.com
</a>&gt;<br>Subject: [Tutor] While Loops and Modules<br>To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>Message-ID: &lt;<a href="mailto:555764.37796.qm@web45105.mail.sp1.yahoo.com">555764.37796.qm@web45105.mail.sp1.yahoo.com
</a>&gt;<br>Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br><br>Hello again to all the wonderfully helpful folks on this list. &nbsp;Today I did my Google homework and I found this neat bit of code for a countdown timer.
<br><br> &nbsp;import time<br>import threading<br>class Timer(threading.Thread):<br> &nbsp; &nbsp;def __init__(self, seconds):<br> &nbsp; &nbsp; &nbsp; &nbsp;self.runTime = seconds<br> &nbsp; &nbsp; &nbsp; &nbsp;threading.Thread.__init__(self)<br> &nbsp; &nbsp;def run(self):<br> &nbsp; &nbsp; &nbsp; &nbsp;
time.sleep(self.runTime)<br> &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Buzzz!!! Time&#39;s up!&quot;<br> &nbsp;t = Timer(30)<br>t.start()<br><br> &nbsp;I don&#39;t understand large chunks of it (don&#39;t know what threading, self, or __init__ mean) but that&#39;s not important at the moment. &nbsp;It works and I will learn the vocab eventually.
<br><br> &nbsp;I also wrote this bit of code for a math challenge which comes in the next part of my game.<br><br> &nbsp;import random<br>startNum = random.choice(range(1, 9))<br>newNum = startNum + 7<br>score = 0<br>print &#39;Start with the number &#39;, startNum, &#39;. &nbsp;Then continuously add 7 to that number until the timer runs out. &nbsp;You have 30 seconds.&#39;
<br><br>answer = int(raw_input(&#39;Enter your answer: &#39;))<br> &nbsp;if newNum == answer:<br> &nbsp; &nbsp;print &#39;That is correct! &nbsp;Keep going.&#39;<br> &nbsp; &nbsp;score = score + 5<br> &nbsp; &nbsp;print &#39;Your score is &#39;, score<br>else:<br>
 &nbsp; &nbsp;print &#39;That is incorrect. &nbsp;Please try again.&#39;<br><br> &nbsp;I understand this part just fine &#39;cause I actually wrote it myself.<br><br> &nbsp;What I need to do now is put these two parts together so that the player will keep adding 7 to the starting number for 30 seconds then the loop breaks. &nbsp;I know I need a loop of some sort and I&#39;m guessing it&#39;s a &#39;while&#39; sort of thing. &nbsp;I couldn&#39;t find what I was looking for when I Googled. &nbsp;I&#39;m not even sure I knew the right search terms. &nbsp;Does anyone know how I&#39;d combine these two modules to make it work?
<br><br><br>---------------------------------<br>Be a better friend, newshound, and know-it-all with Yahoo! Mobile. &nbsp;Try it now.<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <a href="http://mail.python.org/pipermail/tutor/attachments/20071205/e265b7d9/attachment-0001.htm" target="_blank">
http://mail.python.org/pipermail/tutor/attachments/20071205/e265b7d9/attachment-0001.htm</a><br><br>------------------------------<br><br>Message: 6<br>Date: Wed, 05 Dec 2007 23:47:32 -0600<br>From: Luke Paireepinart &lt;
<a href="mailto:rabidpoobear@gmail.com">rabidpoobear@gmail.com</a>&gt;<br>Subject: Re: [Tutor] Mail? What&#39;s that?<br>To: <a href="mailto:raraoz@bigfoot.com">raraoz@bigfoot.com</a><br>Cc: <a href="mailto:tutor@python.org">
tutor@python.org</a><br>Message-ID: &lt;<a href="mailto:47578CF4.4040609@gmail.com">47578CF4.4040609@gmail.com</a>&gt;<br>Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br><br>Ricardo Ar?oz wrote:<br>&gt; So I eventually got to sending mail with python.
<br>&gt; Some articles, trying and google led me to this script:<br>&gt;<br>&gt; import smtplib<br>&gt; import time<br>&gt;<br>&gt; date = time.ctime(time.time( ))<br>&gt; &gt;From = &#39;<a href="mailto:mymail@gmail.com">
mymail@gmail.com</a>&#39;<br>&gt; To = [&#39;<a href="mailto:othermail@hotmail.com">othermail@hotmail.com</a>&#39;, &#39;<a href="mailto:YetOtherMail@yahoo.com">YetOtherMail@yahoo.com</a>&#39;]<br>&gt; Subj = &#39;Hi&#39;
<br>&gt; text = (&#39;From: %s\nTo: %s\nDate: %s\nSubject: %s\n\n&#39;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;% (From, &#39;;&#39;.join(To), date, Subj))<br>&gt;<br>&gt; s = smtplib.SMTP(&#39;<a href="http://smtp.gmail.com" target="_blank">
smtp.gmail.com</a>&#39;)<br>&gt; s.set_debuglevel(1)<br>&gt; s.ehlo()<br>&gt; s.starttls()<br>&gt; s.ehlo()<br>&gt; s.login(&#39;foo&#39;, &#39;bar&#39;)<br>&gt; s.sendmail(From, To, text)<br>&gt; s.close()<br>&gt;<br>&gt;
<br>&gt; So, if there&#39;s someone who really knows this stuff in the neighborhood<br>&gt; I&#39;d like to ask a couple of questions.<br>&gt; What is ehlo and why do I have to call it twice? And set_debuglevel?<br>&gt; If I where to connect through other smtp server the sequence would be
<br>&gt; the exactly the same, say yahoo or hotmail?<br>&gt; Are From: To: Date: and Subject: mandatory in the contents of the<br>&gt; email(text)? &nbsp;Do I have to put &quot;real&quot; address in &nbsp;From when calling<br>&gt; sendmail()? And in the contents?
<br>&gt; Ok, if someone can answer these I&#39;ll be grateful.<br>&gt;<br>&gt; TIA<br>&gt;<br>&gt; Ricardo<br>&gt;<br>Ricardo -<br>I say this in the nicest way possible, but did you RTFM? :)<br>Python has built-in help support on modules.
<br>You should start there, do some Googling, and if you&#39;re stumped, get<br>some help. &nbsp;Not for any other reason than it&#39;ll probably get you 1) more<br>experience at navigating the docs, and 2) a quicker, probably more
<br>detailed response.<br><br>So using Help, we get:<br><br><br>&nbsp;&gt;&gt;&gt; import smtplib<br>&nbsp;&gt;&gt;&gt; help(smtplib)<br>Help on module smtplib:<br><br>NAME<br> &nbsp; &nbsp;smtplib - SMTP/ESMTP client class.<br><br>FILE<br> &nbsp; &nbsp;c:\python24\lib\smtplib.py
<br><br>[snip 10 pages of documentation]<br><br><br>&nbsp;&gt;&gt;&gt; help(smtplib.SMTP.set_debuglevel)<br>Help on method set_debuglevel in module smtplib:<br><br>set_debuglevel(self, debuglevel) unbound smtplib.SMTP method<br>
 &nbsp; &nbsp;Set the debug output level.<br><br> &nbsp; &nbsp;A non-false value results in debug messages for connection and for all<br> &nbsp; &nbsp;messages sent to and received from the server.<br><br>&nbsp;&gt;&gt;&gt; help(smtplib.SMTP.ehlo)<br>Help on method ehlo in module smtplib:
<br><br>ehlo(self, name=&#39;&#39;) unbound smtplib.SMTP method<br> &nbsp; &nbsp;SMTP &#39;ehlo&#39; command.<br> &nbsp; &nbsp;Hostname to send for this command defaults to the FQDN of the local<br> &nbsp; &nbsp;host.<br><br>&nbsp;&gt;&gt;&gt; help(smtplib.SMTP.sendmail
)<br>Help on method sendmail in module smtplib:<br><br>sendmail(self, from_addr, to_addrs, msg, mail_options=[],<br>rcpt_options=[]) unbound smtplib.SMTP method<br> &nbsp; &nbsp;This command performs an entire mail transaction.<br>
<br> &nbsp; &nbsp;The arguments are:<br> &nbsp; &nbsp; &nbsp; &nbsp;- from_addr &nbsp; &nbsp;: The address sending this mail.<br> &nbsp; &nbsp; &nbsp; &nbsp;- to_addrs &nbsp; &nbsp; : A list of addresses to send this mail to. &nbsp;A bare<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string will be treated as a list with 1 address.
<br> &nbsp; &nbsp; &nbsp; &nbsp;- msg &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: The message to send.<br> &nbsp; &nbsp; &nbsp; &nbsp;- mail_options : List of ESMTP options (such as 8bitmime) for the<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mail command.<br> &nbsp; &nbsp; &nbsp; &nbsp;- rcpt_options : List of ESMTP options (such as DSN commands) for
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; all the rcpt commands.<br><br> &nbsp; &nbsp;If there has been no previous EHLO or HELO command this session, this<br> &nbsp; &nbsp;method tries ESMTP EHLO first. &nbsp;If the server does ESMTP, message size<br> &nbsp; &nbsp;and each of the specified options will be passed to it. &nbsp;If EHLO
<br> &nbsp; &nbsp;fails, HELO will be tried and ESMTP options suppressed.<br><br> &nbsp; &nbsp;This method will return normally if the mail is accepted for at least<br> &nbsp; &nbsp;one recipient. &nbsp;It returns a dictionary, with one entry for each<br> &nbsp; &nbsp;recipient that was refused. &nbsp;Each entry contains a tuple of the SMTP
<br> &nbsp; &nbsp;error code and the accompanying error message sent by the server.<br><br> &nbsp; &nbsp;This method may raise the following exceptions:<br><br> &nbsp; &nbsp; SMTPHeloError &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The server didn&#39;t reply properly to<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;the helo greeting.
<br> &nbsp; &nbsp; SMTPRecipientsRefused &nbsp;The server rejected ALL recipients<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(no mail was sent).<br> &nbsp; &nbsp; SMTPSenderRefused &nbsp; &nbsp; &nbsp;The server didn&#39;t accept the from_addr.<br> &nbsp; &nbsp; SMTPDataError &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The server replied with an unexpected
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;error code (other than a refusal of<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a recipient).<br><br> &nbsp; &nbsp;Note: the connection will be open even after an exception is raised.<br><br> &nbsp; &nbsp;Example:<br><br> &nbsp; &nbsp; &gt;&gt;&gt; import smtplib
<br> &nbsp; &nbsp; &gt;&gt;&gt; s=smtplib.SMTP(&quot;localhost&quot;)<br> &nbsp; &nbsp; &gt;&gt;&gt;<br>tolist=[&quot;<a href="mailto:one@one.org">one@one.org</a>&quot;,&quot;<a href="mailto:two@two.org">two@two.org</a>&quot;,&quot;<a href="mailto:three@three.org">
three@three.org</a>&quot;,&quot;<a href="mailto:four@four.org">four@four.org</a>&quot;]<br> &nbsp; &nbsp; &gt;&gt;&gt; msg = &#39;&#39;&#39;\<br> &nbsp; &nbsp; ... From: <a href="mailto:Me@my.org">Me@my.org</a><br> &nbsp; &nbsp; ... Subject: testin&#39;...
<br> &nbsp; &nbsp; ...<br> &nbsp; &nbsp; ... This is a test &#39;&#39;&#39;<br> &nbsp; &nbsp; &gt;&gt;&gt; s.sendmail(&quot;<a href="mailto:me@my.org">me@my.org</a>&quot;,tolist,msg)<br> &nbsp; &nbsp; { &quot;<a href="mailto:three@three.org">three@three.org</a>
&quot; : ( 550 ,&quot;User unknown&quot; ) }<br> &nbsp; &nbsp; &gt;&gt;&gt; s.quit()<br><br> &nbsp; &nbsp;In the above example, the message was accepted for delivery to three<br> &nbsp; &nbsp;of the four addresses, and one was rejected, with the error code
<br> &nbsp; &nbsp;550. &nbsp;If all addresses are accepted, then the method will return an<br> &nbsp; &nbsp;empty dictionary.<br><br>&nbsp;&gt;&gt;&gt;<br><br><br><br><br>So mess around in the built-in docs, then check <a href="http://python.org" target="_blank">
python.org</a>&#39;s docs, and<br>let us know what you find :)<br>Also, try experimenting! pass it stuff that you don&#39;t think will work<br>just to see if maybe it does :D<br>-Luke<br><br><br>------------------------------
<br><br>Message: 7<br>Date: Thu, 6 Dec 2007 10:15:02 +0100<br>From: &quot;Remco Gerlich&quot; &lt;<a href="mailto:remco@gerlich.nl">remco@gerlich.nl</a>&gt;<br>Subject: Re: [Tutor] Best way of learning<br>To: andy &lt;<a href="mailto:geek_show@dsl.pipex.com">
geek_show@dsl.pipex.com</a>&gt;<br>Cc: <a href="mailto:tutor@python.org">tutor@python.org</a><br>Message-ID:<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;<a href="mailto:7ae3ca10712060115r34a7fa33q32a5902fdd0af1b@mail.gmail.com">7ae3ca10712060115r34a7fa33q32a5902fdd0af1b@mail.gmail.com
</a>&gt;<br>Content-Type: text/plain; charset=&quot;utf-8&quot;<br><br>On Dec 5, 2007 11:43 PM, andy &lt;<a href="mailto:geek_show@dsl.pipex.com">geek_show@dsl.pipex.com</a>&gt; wrote:<br><br>&gt; So, after this long-winded introduction, I was hoping to pick the wisdom
<br>&gt; of this list to get some pointers of what to do/not to do to make the<br>&gt; most effective use of the few hours I have to learn how to program using<br>&gt; Python. So, any advice for someone in their mid-40s who would like to
<br>&gt; learn Python in a more methodical and effective manner?<br>&gt;<br><br>In my opinion, the best way to learn _anything_ is to try to do it, and then<br>look around for tips every now and then in the mean time. You&#39;ll connect
<br>much more easily with the information when it&#39;s something you&#39;ve recently<br>struggled with. And practice is the most important part of any learning<br>anyway.<br><br>So, what do you want to do with Python? Any other hobbies you can connect it
<br>with? Perhaps ideas for a dynamic web site or something?<br><br>In my experience, learning something just for abstract knowledge can be fun<br>for a while, but it&#39;s hard to stay committed. And there&#39;s nothing wrong with
<br>that, there&#39;s only so many hours in a day, and the things you actually use<br>in life should probably take precedence :-)<br><br>So if you&#39;ve written small tools, feel like expanding them? Used modules in<br>them that you don&#39;t entirely understand yet, perhaps dive into their docs?
<br><br>Perhaps the Python Challenge ( <a href="http://www.pythonchallenge.com/" target="_blank">http://www.pythonchallenge.com/</a> ) is<br>something for you? It&#39;s at least sideways a little into the hacking spirit,<br>
it&#39;s fun, and it&#39;s a tour of what Python can do - but you&#39;ll have to find<br>the way yourself :-)<br><br>Remco Gerlich<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <a href="http://mail.python.org/pipermail/tutor/attachments/20071206/8eafc022/attachment.htm" target="_blank">
http://mail.python.org/pipermail/tutor/attachments/20071206/8eafc022/attachment.htm</a><br><br>------------------------------<br><br>_______________________________________________<br>Tutor maillist &nbsp;- &nbsp;<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 46, Issue 15<br>*************************************
<br></blockquote></div><br>