Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:Python': 0.05; 'doctest': 0.07; 'try:': 0.07; 'url:blog': 0.09; 'python': 0.09; '"""class': 0.09; 'already.': 0.09; 'docstrings': 0.09; 'explanation': 0.09; 'lawrence': 0.09; 'lines:': 0.09; 'posting.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'url:voidspace': 0.09; 'worse': 0.09; 'advance': 0.10; 'def': 0.10; 'suggest': 0.11; 'language': 0.14; 'library': 0.15; '"""method': 0.16; 'dictionaries': 0.16; 'docstring': 0.16; 'hint': 0.16; 'message-id:@dough.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject: \n ': 0.16; 'subject:object': 0.16; 'subject:oriented': 0.16; 'subject:programming': 0.16; 'this)': 0.16; 'url:oreilly': 0.16; 'url:shtml': 0.16; 'wrote:': 0.17; 'thanks,': 0.18; '>>>': 0.18; 'code,': 0.18; 'python?': 0.20; 'bit': 0.21; 'thanks.': 0.21; 'together.': 0.21; 'oriented': 0.22; 'example': 0.23; 'programming': 0.23; 'mention': 0.23; 'task': 0.23; 'seems': 0.23; 'testing': 0.24; 'pass': 0.25; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'question': 0.27; 'c++': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'trouble': 0.28; '>>>>': 0.29; 'jean': 0.29; 'question:': 0.29; 'url:mailman': 0.29; 'starts': 0.29; 'skip:_ 10': 0.29; 'probably': 0.29; 'class': 0.29; 'unlike': 0.30; 'code': 0.31; 'url:python': 0.32; 'from:addr:yahoo.co.uk': 0.32; 'could': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'programming,': 0.33; 'url:event': 0.33; 'to:addr:python-list': 0.33; 'languages': 0.33; 'thanks': 0.34; 'list': 0.35; 'received:org': 0.36; 'really': 0.36; 'explain': 0.36; 'but': 0.36; 'url:org': 0.36; 'method': 0.36; 'subject:with': 0.36; 'author': 0.37; 'pdf': 0.37; 'does': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'comment': 0.38; 'fact': 0.38; 'object': 0.38; 'some': 0.38; 'url:docs': 0.38; 'url:en': 0.38; 'to:addr:python.org': 0.39; 'little': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'url:mail': 0.40; 'your': 0.60; 'bottom': 0.60; 'skip:u 10': 0.60; 'url:index': 0.61; 'url:%20': 0.63; 'email addr:gmail.com': 0.63; 'making': 0.64; 'here': 0.65; 'difficulty': 0.65; 'august': 0.66; 'news': 0.68; 'url:%1': 0.68; 'prefers': 0.84; 'subject:good': 0.84; 'url:oop': 0.84; 'video:': 0.84; 'fragment': 0.91; 'url:assets': 0.91; 'url:tutorial': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Looking for a good introduction to object oriented programming with Python Date: Mon, 06 Aug 2012 17:17:33 +0100 References: <54b916fe-9e2d-4f9e-b533-b5ecf677c8a5@a19g2000vba.googlegroups.com> <8f1b60a5-0411-4aae-9ee6-0025b493ca2d@m13g2000vbd.googlegroups.com> <94492584-4446-47ff-85c4-749de850561e@b10g2000vbj.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-92-24-124-25.ppp.as43234.net User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: X-Antivirus: avast! (VPS 120806-0, 06/08/2012), Outbound message X-Antivirus-Status: Clean X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 120 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1344269795 news.xs4all.nl 6928 [2001:888:2000:d::a6]:49759 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26633 Please see my comment at the bottom hint hint :) On 06/08/2012 16:38, Ramchandra Apte wrote: > Its a docstring - it documents the function/class > Did you know that docstrings can be used for testing - look at the doctest > standard library module! > try: > > class A: > def method(self): > '''Sample method > This method does the difficult task X. > Call this method with no arguments.'''#docstring > pass > > then type : > > help(A.method) > > And viola! > On 6 August 2012 20:26, Jean Dubois wrote: > >> On 5 aug, 20:28, Mark Lawrence wrote: >>> On 05/08/2012 19:04, Jean Dubois wrote: >>> >>> >>> >>> >>> >>> >>> >>> >>> >>>> On 5 aug, 02:11, shearich...@gmail.com wrote: >>>>> One reason you may be having difficulty is that unlike some languages >> (C++/Java) object-orientation is not a be all and end all in Python, in >> fact you could work with Python for a long time without really 'doing it' >> at all (well other than calling methods/properties on existing API's). >> Having said that here's what I would suggest ... >>> >>>>> Could do worse than this : >>> >>>>> http://www.diveintopython.net/object_oriented_framework/index.html >>> >>>> This example seems to tell you need the concept of dictionaries to >>>> explain object oriented programming, is this really necessary? >>>>> and this >>> >>>>> http://docs.python.org/tutorial/classes.html >>>> Unfortunately, the trouble with this explanation is exactly what made >>>> me ask the original question: it starts from concepts in c++ making it >>>> very hard to understand for someone who does not know that language >>>> already. >>> >>>>> read together. >>> >>>>> Judging by your question this is a probably a little advanced for now >> but you could bookmark it for the future: >>> >>>>> http://www.catonmat.net/blog/learning-python-design-patterns-through-. >> .. >>> >>>>> Here's the corresponding PDF to go with the video: >>> >>>>> http://assets.en.oreilly.com/1/event/45/Practical%20Python%20Patterns. >> .. >>>> Can someone here on this list give a trivial example of what object >>>> oriented programming is, using only Python? >>> >>>> thanks in advance >>>> Jean >>> >>> Try thishttp://www.voidspace.org.uk/python/articles/OOP.shtml??? >>> >>> -- >>> Cheers. >>> >>> Mark Lawrence. >> Thanks, this one is a lot better. Could you just tell me what the use >> is of the following lines: >> """Class docstring.""" >> """Method docstring.""" >> """Method docstring.""" >> Taken from the following code fragment (I really want to understand >> every bit of code, and the author doesn't mention this) >> >> >> class OurClass(object): >> """Class docstring.""" >> >> def __init__(self, arg1, arg2): >> """Method docstring.""" >> self.arg1 = arg1 >> self.arg2 = arg2 >> >> def printargs(self): >> """Method docstring.""" >> print self.arg1 >> print self.arg2 >> >> >> >> thanks in advance >> jean >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > > Ramchandra Apte will you please stop top posting. In your native language you may well but from bottom to top, but this news group prefers reading top to bottom :) Thanks. -- Cheers. Mark Lawrence.