Re: Input from the same file as the script

2006-08-20 Thread Bernhard Mulder
you can (ab)use doc strings. See the doctest module for an example. -- http://mail.python.org/mailman/listinfo/python-list

Re: cloning generator iterators

2006-08-19 Thread Bernhard Mulder
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):

cloning generator iterators

2006-08-19 Thread Bernhard Mulder
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

Re: python number handling - tiny encryption algorithm

2005-11-30 Thread Bernhard Mulder
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