you can (ab)use doc strings. See the doctest module for an example.
--
http://mail.python.org/mailman/listinfo/python-list
Oops. Got the indentation wrong. Here is the corrected version:
def generator(self):
while True:
while True:
if (yield 1):
if (yield 1):
break
self.n = 2
while (yield self.n):
I have something like the following (using Python 2.5 syntax):
class adapt(object):
def __init__(self):
self.iterator = self.generator()
self.n = 0
def generator(self):
while True:
while True:
if (yield 1):
if (yield 1
One systematic, if maybe clumsy way, is to mimic the C arithmetic
operations more closely in Python. If you do, for example, a left shift
in C, the result is always returned in a certain precision, 64 bits in
the example below. In python, no bits are lost, so you have to force the
result into t