Python doesn't have a way to clone generators.

At least for a lot of simple cases, however, it's pretty obvious what cloning them should do, and being able to do so would be handy. But for a lot of other cases, it's not at all obvious.

For example, if the generator is using another iterator (one which isn't a generator itself; otherwise the answer would be obvious), like a file, what should happen when you clone it? Does it share the same file iterator? Or get a new iterator that references the same file handle under the covers? Or one that references a dup of the file handle?

So, let's look at what it would take to clone a generator, and what the choices are, and how you'd implement them.
5

Every time someone has a good idea, they believe it should be in the stdlib. After all, it's useful to many people, and what's the harm? But of course there is a harm.

The Python community has evolved a rough set of unwritten guidelines for how to make the decision, but, being unwritten, it's pretty hard for an outsider/newcomer to determine them. On top of that, over the past couple of years, those guidelines have recently changed dramatically.
3
Blog Archive
About Me
About Me
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.