[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Working on Retro 80s Game SDK, Looking for general support



Note you can get basically the same functionality using the built-in assert statement and running the program through pdb, as in:

python -m pdb myprogram.py

Nice thing about that is that it drops into the debugger right away so that you can set breakpoints if desired. Plus it will drop into the debugger at any uncaught exception, not just failed asserts.

To run it with asserts turned off, use the -O python cmd line option.

-Casey

On Jan 7, 2009, at 4:51 PM, Jake b wrote:

On Wed, Jan 7, 2009 at 2:00 AM, Patrick Mullen <saluk64007@xxxxxxxxx> wrote:
On Tue, Jan 6, 2009 at 10:59 PM, Jake b <ninmonkeys@xxxxxxxxx> wrote:
through, I use the "assert" statement to make sure that the frame counter is no
longer progressing.  Later, if I change some of the animation code
somewhere that
might mess up the play_3_times behavior, when i run the tests that
test will error,
and I'll know I broke something.

Do you use the assert statement, or do you have a function like this?

def _assert(exp, msg=""):
	"""An assert() function.
source: http://www.gamedev.net/community/forums/topic.asp?topic_id=496793 """
	if __debug__ and not exp:
		import pdb
print "\n_assert failed:\n\t%s\n" % msg # or: simple: print "_assert failed: ", msg
		pdb.set_trace()

--
Jake