optional pass? (was Re: Dr. Dobb's Python-URL! - weekly Python news and links (Mar 26))

phil hunt philh at comuno.freeserve.co.uk
Fri Mar 29 12:44:53 EST 2002


On Fri, 29 Mar 2002 12:45:50 +0000 (UTC), Alexandre Fayolle <alf at logilab.fr> wrote:
>In article <slrnaa6sfc.d02.philh at comuno.freeserve.co.uk>, phil hunt wrote:
>> True, but i still have to remove the passes when i want to implement 
>> the class.
>
>Why don't you put a docstring ? It will help you document precisely what
>you had in mind when writing the class, and you can keep it when you
>actually write the code. 

3 reasons.

(1) Sometimes the functionality of the method is too obvious to 
require 
one, e.g.:

class Key:
   def encrypt(self, plainText):
   def decrypt(self, cipherText):

I would really hope this is obvious enough not to need one.


(2) Also, I often put a big comment for the whole class, rather than 
scatter little comments for each method, e.g.:


"""***
Foo does blah blah blah

rest
of
long
comment
goes 
in 
here
***"""

class Foo:
   def method1(self):
   def method2(self):
   def method3(self):
   def method4(self):
   def method5(self):


(3) sometimes the pass-less code isn't a function definition, e.g.:


if a == "one":
   do_something()
elif a == "two":
elif a == "three":
else:


Here I've only implemented 1 of the 4 possibilities. I want to be 
able to run my code to test what I've written, before implementing 
the other 3.

-- 
<"><"><"> Philip Hunt <philh at comuno.freeserve.co.uk> <"><"><">
"I would guess that he really believes whatever is politically 
advantageous for him to believe." 
                        -- Alison Brooks, referring to Michael
                              Portillo, on soc.history.what-if



More information about the Python-list mailing list