[Tutor] Are Empty "Placeholder" Functions possible?

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Thu May 26 20:53:49 CEST 2005



> Is there a way to create an empty function definition with no lines of
> code in it? In my coding style I will often do this ( in other languages
> ) for RAD just to remind myself that I will need to implement the
> function later.

Hi Nick,

I agree with the others; using the no-op statement 'pass' is probably the
way to go here.

If I'm paranoid, I sometimes use a body that just raises a
NotImplementedError exception:

######
>>> def functionIHaventWrittenYet():
...     raise NotImplementedError
...
>>> functionIHaventWrittenYet()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 2, in functionIHaventWrittenYet
NotImplementedError
######

but, often, just putting in 'pass' stubs is enough.


Best of wishes!



More information about the Tutor mailing list