This repository was archived by the owner on Aug 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.txt
64 lines (43 loc) · 1.42 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
**This package has been archived. It was only a workaround to make generator_tools work with Python 2.7 and is not suitable for use in new projects.**
generator_tools
===============
generator_tools is a package used to provide facilities for generators such as
copying and pickling.
This project has been forked from version 0.3.6
http://www.fiber-space.de/generator_tools/doc/generator_tools.html.
It has been modified to work with Python 2.7, and support for earlier Python versions has
been dropped.
INSTALLATION
Just type
python setup.py install
while being in the root directory of the project. This will place generator_tools in
Python's site-packages directory.
DOCUMENTATION
http://www.fiber-space.de/generator_tools/doc/generator_tools.html
The same document can be found in the local installation at
site-packages/generator_tools/doc
USAGE
Here is some simple use case:
from generator_tools.copygenerators import*
from generator_tools.picklegenerators import*
def f(start):
i = start
while i<start+10:
yield i
i+=1
>>> f_gen = f(5)
>>> f_gen.next()
5
>>> f_gen.next()
6
>>> g_gen = copy_generator(f_gen)
>>> h_gen = copy_generator(f_gen)
>>> g_gen.next()
7
>>> h_gen.next()
7
>>> pickler = GeneratorPickler("test.pkl")
>>> pickler.pickle_generator(g_gen)
>>> k_gen = pickler.unpickle_generator()
>>> list(g_gen) == list(k_gen)
True