[Tutor] Tutor Digest, Vol 117, Issue 28

Satheesan Varier satheesan.varier at gmail.com
Sun Nov 17 13:19:50 CET 2013


class myclass():

              def test(self):
                    print "print this line"


if __name__ == '__main__':
          myclass.run()


You can do the test run with an instance of that class, as follows:

>>> class myclass():

              def test(self):
                    print "print this line"


>>> k=myclass()

>>> myclass.test(k)
print this line




On Sun, Nov 17, 2013 at 3:40 AM, <tutor-request at python.org> wrote:

> Send Tutor mailing list submissions to
>         tutor at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>         tutor-request at python.org
>
> You can reach the person managing the list at
>         tutor-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
>    1. Class attribute error (reutest)
>    2. Re: basic function concept (Dominik George)
>    3. Re: Class attribute error (Dominik George)
>    4. Re: basic function concept (Alan Gauld)
>    5. Re: Class attribute error (Alan Gauld)
>    6. Re: basic function concept (Alex Kleider)
>    7. Fwd:  Need help on Python API programmig (Amit Saha)
>    8. loop running twice? (Byron Ruffin)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 16 Nov 2013 09:13:13 -0800 (PST)
> From: reutest <reuben.dlink at gmail.com>
> To: tutor at python.org
> Subject: [Tutor] Class attribute error
> Message-ID: <1384621993288-5039199.post at n6.nabble.com>
> Content-Type: text/plain; charset=us-ascii
>
> class myclass():
>
>               def test(self):
>                     print "print this line"
>
>
> if __name__ == '__main__':
>           myclass.run()
>
>
>
> --
> View this message in context:
> http://python.6.x6.nabble.com/Class-attribute-error-tp5039199.html
> Sent from the Python - tutor mailing list archive at Nabble.com.
>
>
> ------------------------------
>
> Message: 2
> Date: Sun, 17 Nov 2013 00:56:10 +0100
> From: Dominik George <nik at naturalnet.de>
> To: Byron Ruffin <byron.ruffin at g.austincc.edu>
> Cc: tutor at python.org
> Subject: Re: [Tutor] basic function concept
> Message-ID: <20131116235610.GT5095 at keks.naturalnet.de>
> Content-Type: text/plain; charset="utf-8"
>
> > main()
> >
> > Can someone tell me why main is not being given any arguments?
>
> Because you didn't write any there.
>
> -nik
>
> --
> Wer den Gr?nkohl nicht ehrt, ist der Mettwurst nicht wert!
>
> PGP-Fingerprint: 3C9D 54A4 7575 C026 FB17  FD26 B79A 3C16 A0C4 F296
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: signature.asc
> Type: application/pgp-signature
> Size: 905 bytes
> Desc: Digital signature
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20131117/eef9967c/attachment-0001.sig
> >
>
> ------------------------------
>
> Message: 3
> Date: Sun, 17 Nov 2013 00:55:11 +0100
> From: Dominik George <nik at naturalnet.de>
> To: reutest <reuben.dlink at gmail.com>
> Cc: tutor at python.org
> Subject: Re: [Tutor] Class attribute error
> Message-ID: <20131116235510.GS5095 at keks.naturalnet.de>
> Content-Type: text/plain; charset="utf-8"
>
> On Sat, Nov 16, 2013 at 09:13:13AM -0800, reutest wrote:
> > class myclass():
> >
> >             def test(self):
> >                   print "print this line"
> >
> >
> > if __name__ == '__main__':
> >           myclass.run()
>
> Is that a question?
>
> If I were to guess, I'd say you should have asked "Why does this say
> that myclass does not havea run method?". Then the simple answer is:
> Because, well, it doesn't! Why do you expect it to have one?
>
> -nik
>
> --
> Wer den Gr?nkohl nicht ehrt, ist der Mettwurst nicht wert!
>
> PGP-Fingerprint: 3C9D 54A4 7575 C026 FB17  FD26 B79A 3C16 A0C4 F296
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: signature.asc
> Type: application/pgp-signature
> Size: 905 bytes
> Desc: Digital signature
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20131117/5d249c0d/attachment-0001.sig
> >
>
> ------------------------------
>
> Message: 4
> Date: Sun, 17 Nov 2013 00:51:47 +0000
> From: Alan Gauld <alan.gauld at btinternet.com>
> To: tutor at python.org
> Subject: Re: [Tutor] basic function concept
> Message-ID: <l693uo$29e$1 at ger.gmane.org>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 16/11/13 21:20, Byron Ruffin wrote:
> > def main(x, y, z):
> >
> >      print (x, y, z)
> >
> > def funct():
> >      x = 1
> >      y = 2
> >      z = 3
> >
> >      return x, y, z
> >
> >
> > main()
> >
> >
> > Can someone tell me why main is not being given any arguments?
>
> Because somebody made a mistake.
> I don't know if this is your code or something you found in a
> book or web page but whichever it's an error and Python won't
> run it.
>
> Also funct() is a waste of space since its never used...
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.flickr.com/photos/alangauldphotos
>
>
>
> ------------------------------
>
> Message: 5
> Date: Sun, 17 Nov 2013 00:54:40 +0000
> From: Alan Gauld <alan.gauld at btinternet.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Class attribute error
> Message-ID: <l69445$5eu$1 at ger.gmane.org>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 16/11/13 17:13, reutest wrote:
> > class myclass():
> >
> >             def test(self):
> >                   print "print this line"
> >
> >
> > if __name__ == '__main__':
> >            myclass.run()
>
>
> If you have a question it helps if you ask it rather than have us guess.
>
> In this case I'm guessing you got an error and you are wondering why?
>
> It's because you are calling the run() class method of myclass. And
> there is no such method.
>
> If that's not your question please post again with a bit more of a clue
> about what you want to know.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.flickr.com/photos/alangauldphotos
>
>
>
> ------------------------------
>
> Message: 6
> Date: Sat, 16 Nov 2013 21:16:54 -0800
> From: Alex Kleider <akleider at sonic.net>
> To: tutor at python.org
> Subject: Re: [Tutor] basic function concept
> Message-ID: <a64d1ea2366f47355b5708c42e4a58c6 at sonic.net>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> On 2013-11-16 13:20, Byron Ruffin wrote:
> > def main(x, y, z):
> >
> > ??? print (x, y, z)
> >
> > def funct():
> > ??? x = 1
> > ??? y = 2
> > ??? z = 3
> >
> > ??? return x, y, z
> >
> > main()
> >
> > Can someone tell me why main is not being given any arguments?
>
> Because you didn't give it any.
> Try
> main(funct())
> instead.
>
>
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > To unsubscribe or change subscription options:
> > https://mail.python.org/mailman/listinfo/tutor
>
>
> ------------------------------
>
> Message: 7
> Date: Sun, 17 Nov 2013 17:36:27 +1000
> From: Amit Saha <amitsaha.in at gmail.com>
> To: "tutor at python.org" <tutor at python.org>
> Subject: [Tutor] Fwd:  Need help on Python API programmig
> Message-ID:
>         <
> CANODV3kXPNTYs093fkH4q+gEBG9ixpBrj9f-LYyGPaUh_8nORw at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hi John,
>
> Perhaps your answer was directed towards Sourav.
>
> CCing tutor.
>
>
>
>
> ---------- Forwarded message ----------
> From: John Steedman <johnsteedman360 at gmail.com>
> Date: Sun, Nov 17, 2013 at 6:26 AM
> Subject: Re: [Tutor] Need help on Python API programmig
> To: Amit Saha <amitsaha.in at gmail.com>
>
>
> Hi Amit,
>
> I've been using Django Rest Framework for developing a database-driven
> API.  If you choose to follow their tutorial, you may accomplish your
> goal quite quickly while learning a lot about web APIs and quite good
> engineering at the same time. Tastypie is a similar option.
>
> John
>
> On Fri, Nov 15, 2013 at 9:14 PM, Amit Saha <amitsaha.in at gmail.com> wrote:
> > Hello Sourav,
> >
> > On 16/11/2013 6:53 AM, "Sourav Biswas" <sobisw at gmail.com> wrote:
> >>
> >> Hi All,
> >>
> >> This is my first post. I want to learn API programming with Python. I
> have
> >> basic knowledge of Python Programming. Could you please let me know the
> >> starting points for this programming.
> >
> > Since your question is fairly vague, could you please describe what you
> are
> > trying to learn? An API is an interface. It can be an operating system
> > interface, a vehicle web API or simply a web API.
> >
> > Some more details will be a lot of help.
> >
> > Best, Amit.
> >
> >
>
>
>
> --
> http://echorand.me
>
>
> ------------------------------
>
> Message: 8
> Date: Sat, 16 Nov 2013 19:00:47 -0600
> From: Byron Ruffin <byron.ruffin at g.austincc.edu>
> To: tutor at python.org
> Subject: [Tutor] loop running twice?
> Message-ID:
>         <
> CAOsa8feQWPeKkYof9u69niUr8Dut-kj-2fKxdL0kYHTp2-H1yw at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> def main():
>
>     goal, apr, deposit = getSavingsDetails()
>     determineMonthsTilSaved( goal, apr, deposit )
>
>     months = determineMonthsTilSaved(goal, apr, deposit)
>
>     summarize( months )
>
> def getSavingsDetails():
>     """
>     goal = float( input( "Principal sought? $" ) )
>     apr = float( input( "Interest rate? " ) )
>     deposit = float( input( "Deposit? $" ) )
>     """
>     goal = 1000.0
>     apr = .05
>     deposit = 100
>     return goal, apr, deposit
>
> def determineMonthsTilSaved( goal, apr, deposit ):
>     months = 0
>     saved = 0
>     totalInterest = 0.0
>
>
>
>
>     while saved < goal:
>         interest = saved * apr / 12
>         totalInterest += interest
>         saved += (deposit + interest)
>         months += 1
>         print( months, ("%.2f" % saved), ("%.2f" % totalInterest) )
>
>     return months
>
> def summarize( months ):
>     print( "Saved! It took ", months // 12, "years and", months % 12,
> "months." )
>
> main()
>
>
> When this is run it appears that determineMonthsTilSaved is running twice
> before the loop ends.  It is supposed to run until saved > than goal, but
> look at the output.  It runs again even after saved > goal.  Help please?
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20131116/26f2f3b0/attachment.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> https://mail.python.org/mailman/listinfo/tutor
>
>
> ------------------------------
>
> End of Tutor Digest, Vol 117, Issue 28
> **************************************
>



-- 
Warm regards.

Satheesan Varier
860 (970) 2732
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131117/30241fdf/attachment-0001.html>


More information about the Tutor mailing list