pre-PEP for optional 'pass'
Duncan Booth
duncan at NOSPAMrcp.co.uk
Tue Apr 16 04:18:55 EDT 2002
philh at comuno.freeserve.co.uk (phil hunt) wrote in
news:slrnabmoci.dhk.philh at comuno.freeserve.co.uk:
> (1) Convenience
>
> I would like to be able to write as code classes and functions
> without implementing the body to start with, e.g.:
>
>
> class MyClass:
> def __init__(self, x, ,y, z):
> def getTwiddle(self):
> def setTwiddle(self, twiddle):
>
>
> At the moment if I want to do this I have to put pass in and then
> take them out again. A minor inconvenience, to be sure, but one that
> niggles slightly due to the highly exploratory style of coding I
> often use.
You should always head each method and class with a docstring.
Apart from being incredibly useful when you come back to the methods some
months later and cannot remember what they did, this has exactly the effect
you wanted of making 'pass' optional:
class MyClass:
'''A simple class'''
def __init__(self, x, ,y, z): '''MyClass constructor'''
def getTwiddle(self): '''Get a twiddle'''
def setTwiddle(self, twiddle): '''Set a twiddle'''
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list