<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">class myclass():</span><br style="font-family:arial,sans-serif;font-size:13px"><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">              def test(self):</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">                    print "print this line"</span><br style="font-family:arial,sans-serif;font-size:13px"><br style="font-family:arial,sans-serif;font-size:13px">
<br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">if __name__ == '__main__':</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">          myclass.run()</span><br style="font-family:arial,sans-serif;font-size:13px">
<br style="font-family:arial,sans-serif;font-size:13px"><div><br></div><div>You can do the test run with an instance of that class, as follows:</div><div><br></div><div><div>>>> class myclass():</div><div><br></div>
<div>              def test(self):</div><div>                    print "print this line"</div><div><br></div><div>                    </div><div>>>> k=myclass()</div></div><div><br></div><div><div>>>> myclass.test(k)</div>
<div>print this line</div></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Nov 17, 2013 at 3:40 AM,  <span dir="ltr"><<a href="mailto:tutor-request@python.org" target="_blank">tutor-request@python.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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="https://mail.python.org/mailman/listinfo/tutor" target="_blank">https://mail.python.org/mailman/listinfo/tutor</a><br>
or, via email, send a message with subject or body 'help' 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 "Re: Contents of Tutor digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. Class attribute error (reutest)<br>
   2. Re: basic function concept (Dominik George)<br>
   3. Re: Class attribute error (Dominik George)<br>
   4. Re: basic function concept (Alan Gauld)<br>
   5. Re: Class attribute error (Alan Gauld)<br>
   6. Re: basic function concept (Alex Kleider)<br>
   7. Fwd:  Need help on Python API programmig (Amit Saha)<br>
   8. loop running twice? (Byron Ruffin)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Sat, 16 Nov 2013 09:13:13 -0800 (PST)<br>
From: reutest <<a href="mailto:reuben.dlink@gmail.com">reuben.dlink@gmail.com</a>><br>
To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>
Subject: [Tutor] Class attribute error<br>
Message-ID: <<a href="mailto:1384621993288-5039199.post@n6.nabble.com">1384621993288-5039199.post@n6.nabble.com</a>><br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
class myclass():<br>
<br>
              def test(self):<br>
                    print "print this line"<br>
<br>
<br>
if __name__ == '__main__':<br>
          myclass.run()<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://python.6.x6.nabble.com/Class-attribute-error-tp5039199.html" target="_blank">http://python.6.x6.nabble.com/Class-attribute-error-tp5039199.html</a><br>
Sent from the Python - tutor mailing list archive at Nabble.com.<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Sun, 17 Nov 2013 00:56:10 +0100<br>
From: Dominik George <<a href="mailto:nik@naturalnet.de">nik@naturalnet.de</a>><br>
To: Byron Ruffin <<a href="mailto:byron.ruffin@g.austincc.edu">byron.ruffin@g.austincc.edu</a>><br>
Cc: <a href="mailto:tutor@python.org">tutor@python.org</a><br>
Subject: Re: [Tutor] basic function concept<br>
Message-ID: <<a href="mailto:20131116235610.GT5095@keks.naturalnet.de">20131116235610.GT5095@keks.naturalnet.de</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
> main()<br>
><br>
> Can someone tell me why main is not being given any arguments?<br>
<br>
Because you didn't write any there.<br>
<br>
-nik<br>
<br>
--<br>
Wer den Gr?nkohl nicht ehrt, ist der Mettwurst nicht wert!<br>
<br>
PGP-Fingerprint: 3C9D 54A4 7575 C026 FB17  FD26 B79A 3C16 A0C4 F296<br>
-------------- next part --------------<br>
A non-text attachment was scrubbed...<br>
Name: signature.asc<br>
Type: application/pgp-signature<br>
Size: 905 bytes<br>
Desc: Digital signature<br>
URL: <<a href="http://mail.python.org/pipermail/tutor/attachments/20131117/eef9967c/attachment-0001.sig" target="_blank">http://mail.python.org/pipermail/tutor/attachments/20131117/eef9967c/attachment-0001.sig</a>><br>

<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Sun, 17 Nov 2013 00:55:11 +0100<br>
From: Dominik George <<a href="mailto:nik@naturalnet.de">nik@naturalnet.de</a>><br>
To: reutest <<a href="mailto:reuben.dlink@gmail.com">reuben.dlink@gmail.com</a>><br>
Cc: <a href="mailto:tutor@python.org">tutor@python.org</a><br>
Subject: Re: [Tutor] Class attribute error<br>
Message-ID: <<a href="mailto:20131116235510.GS5095@keks.naturalnet.de">20131116235510.GS5095@keks.naturalnet.de</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
On Sat, Nov 16, 2013 at 09:13:13AM -0800, reutest wrote:<br>
> class myclass():<br>
><br>
>             def test(self):<br>
>                   print "print this line"<br>
><br>
><br>
> if __name__ == '__main__':<br>
>           myclass.run()<br>
<br>
Is that a question?<br>
<br>
If I were to guess, I'd say you should have asked "Why does this say<br>
that myclass does not havea run method?". Then the simple answer is:<br>
Because, well, it doesn't! Why do you expect it to have one?<br>
<br>
-nik<br>
<br>
--<br>
Wer den Gr?nkohl nicht ehrt, ist der Mettwurst nicht wert!<br>
<br>
PGP-Fingerprint: 3C9D 54A4 7575 C026 FB17  FD26 B79A 3C16 A0C4 F296<br>
-------------- next part --------------<br>
A non-text attachment was scrubbed...<br>
Name: signature.asc<br>
Type: application/pgp-signature<br>
Size: 905 bytes<br>
Desc: Digital signature<br>
URL: <<a href="http://mail.python.org/pipermail/tutor/attachments/20131117/5d249c0d/attachment-0001.sig" target="_blank">http://mail.python.org/pipermail/tutor/attachments/20131117/5d249c0d/attachment-0001.sig</a>><br>

<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Sun, 17 Nov 2013 00:51:47 +0000<br>
From: Alan Gauld <<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>><br>
To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>
Subject: Re: [Tutor] basic function concept<br>
Message-ID: <l693uo$29e$<a href="mailto:1@ger.gmane.org">1@ger.gmane.org</a>><br>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br>
<br>
On 16/11/13 21:20, Byron Ruffin wrote:<br>
> def main(x, y, z):<br>
><br>
>      print (x, y, z)<br>
><br>
> def funct():<br>
>      x = 1<br>
>      y = 2<br>
>      z = 3<br>
><br>
>      return x, y, z<br>
><br>
><br>
> main()<br>
><br>
><br>
> Can someone tell me why main is not being given any arguments?<br>
<br>
Because somebody made a mistake.<br>
I don't know if this is your code or something you found in a<br>
book or web page but whichever it's an error and Python won't<br>
run it.<br>
<br>
Also funct() is a waste of space since its never used...<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>
<a href="http://www.flickr.com/photos/alangauldphotos" target="_blank">http://www.flickr.com/photos/alangauldphotos</a><br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 5<br>
Date: Sun, 17 Nov 2013 00:54:40 +0000<br>
From: Alan Gauld <<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>><br>
To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>
Subject: Re: [Tutor] Class attribute error<br>
Message-ID: <l69445$5eu$<a href="mailto:1@ger.gmane.org">1@ger.gmane.org</a>><br>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br>
<br>
On 16/11/13 17:13, reutest wrote:<br>
> class myclass():<br>
><br>
>             def test(self):<br>
>                   print "print this line"<br>
><br>
><br>
> if __name__ == '__main__':<br>
>            myclass.run()<br>
<br>
<br>
If you have a question it helps if you ask it rather than have us guess.<br>
<br>
In this case I'm guessing you got an error and you are wondering why?<br>
<br>
It's because you are calling the run() class method of myclass. And<br>
there is no such method.<br>
<br>
If that's not your question please post again with a bit more of a clue<br>
about what you want to know.<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>
<a href="http://www.flickr.com/photos/alangauldphotos" target="_blank">http://www.flickr.com/photos/alangauldphotos</a><br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 6<br>
Date: Sat, 16 Nov 2013 21:16:54 -0800<br>
From: Alex Kleider <<a href="mailto:akleider@sonic.net">akleider@sonic.net</a>><br>
To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>
Subject: Re: [Tutor] basic function concept<br>
Message-ID: <<a href="mailto:a64d1ea2366f47355b5708c42e4a58c6@sonic.net">a64d1ea2366f47355b5708c42e4a58c6@sonic.net</a>><br>
Content-Type: text/plain; charset=UTF-8; format=flowed<br>
<br>
On 2013-11-16 13:20, Byron Ruffin wrote:<br>
> def main(x, y, z):<br>
><br>
> ??? print (x, y, z)<br>
><br>
> def funct():<br>
> ??? x = 1<br>
> ??? y = 2<br>
> ??? z = 3<br>
><br>
> ??? return x, y, z<br>
><br>
> main()<br>
><br>
> Can someone tell me why main is not being given any arguments?<br>
<br>
Because you didn't give it any.<br>
Try<br>
main(funct())<br>
instead.<br>
<br>
<br>
><br>
> _______________________________________________<br>
> Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
> To unsubscribe or change subscription options:<br>
> <a href="https://mail.python.org/mailman/listinfo/tutor" target="_blank">https://mail.python.org/mailman/listinfo/tutor</a><br>
<br>
<br>
------------------------------<br>
<br>
Message: 7<br>
Date: Sun, 17 Nov 2013 17:36:27 +1000<br>
From: Amit Saha <<a href="mailto:amitsaha.in@gmail.com">amitsaha.in@gmail.com</a>><br>
To: "<a href="mailto:tutor@python.org">tutor@python.org</a>" <<a href="mailto:tutor@python.org">tutor@python.org</a>><br>
Subject: [Tutor] Fwd:  Need help on Python API programmig<br>
Message-ID:<br>
        <<a href="mailto:CANODV3kXPNTYs093fkH4q%2BgEBG9ixpBrj9f-LYyGPaUh_8nORw@mail.gmail.com">CANODV3kXPNTYs093fkH4q+gEBG9ixpBrj9f-LYyGPaUh_8nORw@mail.gmail.com</a>><br>
Content-Type: text/plain; charset=ISO-8859-1<br>
<br>
Hi John,<br>
<br>
Perhaps your answer was directed towards Sourav.<br>
<br>
CCing tutor.<br>
<br>
<br>
<br>
<br>
---------- Forwarded message ----------<br>
From: John Steedman <<a href="mailto:johnsteedman360@gmail.com">johnsteedman360@gmail.com</a>><br>
Date: Sun, Nov 17, 2013 at 6:26 AM<br>
Subject: Re: [Tutor] Need help on Python API programmig<br>
To: Amit Saha <<a href="mailto:amitsaha.in@gmail.com">amitsaha.in@gmail.com</a>><br>
<br>
<br>
Hi Amit,<br>
<br>
I've been using Django Rest Framework for developing a database-driven<br>
API.  If you choose to follow their tutorial, you may accomplish your<br>
goal quite quickly while learning a lot about web APIs and quite good<br>
engineering at the same time. Tastypie is a similar option.<br>
<br>
John<br>
<br>
On Fri, Nov 15, 2013 at 9:14 PM, Amit Saha <<a href="mailto:amitsaha.in@gmail.com">amitsaha.in@gmail.com</a>> wrote:<br>
> Hello Sourav,<br>
><br>
> On 16/11/2013 6:53 AM, "Sourav Biswas" <<a href="mailto:sobisw@gmail.com">sobisw@gmail.com</a>> wrote:<br>
>><br>
>> Hi All,<br>
>><br>
>> This is my first post. I want to learn API programming with Python. I have<br>
>> basic knowledge of Python Programming. Could you please let me know the<br>
>> starting points for this programming.<br>
><br>
> Since your question is fairly vague, could you please describe what you are<br>
> trying to learn? An API is an interface. It can be an operating system<br>
> interface, a vehicle web API or simply a web API.<br>
><br>
> Some more details will be a lot of help.<br>
><br>
> Best, Amit.<br>
><br>
><br>
<br>
<br>
<br>
--<br>
<a href="http://echorand.me" target="_blank">http://echorand.me</a><br>
<br>
<br>
------------------------------<br>
<br>
Message: 8<br>
Date: Sat, 16 Nov 2013 19:00:47 -0600<br>
From: Byron Ruffin <<a href="mailto:byron.ruffin@g.austincc.edu">byron.ruffin@g.austincc.edu</a>><br>
To: <a href="mailto:tutor@python.org">tutor@python.org</a><br>
Subject: [Tutor] loop running twice?<br>
Message-ID:<br>
        <<a href="mailto:CAOsa8feQWPeKkYof9u69niUr8Dut-kj-2fKxdL0kYHTp2-H1yw@mail.gmail.com">CAOsa8feQWPeKkYof9u69niUr8Dut-kj-2fKxdL0kYHTp2-H1yw@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
def main():<br>
<br>
    goal, apr, deposit = getSavingsDetails()<br>
    determineMonthsTilSaved( goal, apr, deposit )<br>
<br>
    months = determineMonthsTilSaved(goal, apr, deposit)<br>
<br>
    summarize( months )<br>
<br>
def getSavingsDetails():<br>
    """<br>
    goal = float( input( "Principal sought? $" ) )<br>
    apr = float( input( "Interest rate? " ) )<br>
    deposit = float( input( "Deposit? $" ) )<br>
    """<br>
    goal = 1000.0<br>
    apr = .05<br>
    deposit = 100<br>
    return goal, apr, deposit<br>
<br>
def determineMonthsTilSaved( goal, apr, deposit ):<br>
    months = 0<br>
    saved = 0<br>
    totalInterest = 0.0<br>
<br>
<br>
<br>
<br>
    while saved < goal:<br>
        interest = saved * apr / 12<br>
        totalInterest += interest<br>
        saved += (deposit + interest)<br>
        months += 1<br>
        print( months, ("%.2f" % saved), ("%.2f" % totalInterest) )<br>
<br>
    return months<br>
<br>
def summarize( months ):<br>
    print( "Saved! It took ", months // 12, "years and", months % 12,<br>
"months." )<br>
<br>
main()<br>
<br>
<br>
When this is run it appears that determineMonthsTilSaved is running twice<br>
before the loop ends.  It is supposed to run until saved > than goal, but<br>
look at the output.  It runs again even after saved > goal.  Help please?<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.python.org/pipermail/tutor/attachments/20131116/26f2f3b0/attachment.html" target="_blank">http://mail.python.org/pipermail/tutor/attachments/20131116/26f2f3b0/attachment.html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/tutor" target="_blank">https://mail.python.org/mailman/listinfo/tutor</a><br>
<br>
<br>
------------------------------<br>
<br>
End of Tutor Digest, Vol 117, Issue 28<br>
**************************************<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Warm regards.<br><br>Satheesan Varier<br>860 (970) 2732</div>
</div>