Dr. Dobb's Python-URL! - weekly Python news and links (Mar 26)
David Ascher
DavidA at ActiveState.com
Thu Mar 28 18:43:20 EST 2002
phil hunt wrote:
> And Guido's statement supports my suggestion that pass be made
> optional in Python. Consider, when someone is designing a class,
> one could write an outline like this:
>
> class BaseClass:
>
> class MyClass(BaseClass):
> def __init__(self):
> def method1(self, a, b, c):
> def method2(self, d, e):
> def method3(self, f):
>
> It is perfectly clear what this means. But unfortunately, as Python
> stands today, it is syntactically invalid, one would have to say:
>
> class BaseClass:
> pass
>
> class MyClass(BaseClass):
> def __init__(self):
> pass
> def method1(self, a, b, c):
> pass
> def method2(self, d, e):
> pass
> def method3(self, f):
> pass
May I suggest that you instead do:
>>> class MyClass:
... def do_this(self):
... "this function would do this"
... def do_that(self):
... "while this function would do that"
...
>>>
and use the docstrings as a placeholder for the actions of the function
-- typically something that's foremost in your mind when you're
pseudocoding, and it counts as a statement as far as the parser's
concerned (hence is syntactically valid), and at the same time, you've
already got docstrings ready for you when you start to implement.
--david
More information about the Python-list
mailing list