[Tutor] Are Empty "Placeholder" Functions possible?

Nick Lunt nick at javacat.f2s.com
Thu May 26 19:06:41 CEST 2005


Hi John,

you can use 'pass' . This works the same as with exceptions, eg

try:
	open('somefile')
except IOError:
	pass

so we can have

class doNothing:
	def __init__(self):
		pass
	def boring(self, other):
		pass

Hope that helps :)
Nick

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org]On
Behalf Of Gooch, John
Sent: 26 May 2005 16:43
To: tutor at python.org
Subject: [Tutor] Are Empty "Placeholder" Functions possible?


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.

Example: For a file handling class, I may need functions such as
copy,delete,move,etc so I want to start off with:

class FileHandler:
	def __init__(self):

	def copy(self):

	def delete(self):
	.
	.
	.


then in my driver/aka testing file:

import FileHandler

def main()
	MyHandler = FileHandler()
	print "Handler Created."

main()




Right now, this won't work as the compliler will error on functions with
nothing in them. Is there a "no-op", "do nothing", or some similar command I
can put in the empty functions to keep the compiler/interpreter from
erroring on them? This would really help speed up my development so that I
can create the class skeleton quickly and then implement each function and
test it as I go.


Thank You,


John A. Gooch
Systems Administrator
IT - Tools
EchoStar Satellite L.L.C.
9601 S. Meridian Blvd.
Englewood, CO  80112
Desk: 720-514-5708


_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor


--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 266.11.17 - Release Date: 25/05/2005




More information about the Tutor mailing list