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 <jeandubois...@gmail.com> wrote: > On 5 aug, 20:28, Mark Lawrence <breamore...@yahoo.co.uk> 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 >
-- http://mail.python.org/mailman/listinfo/python-list