[Python-ideas] How can I get own instance of generator in itself code
Chris Rebert
pyideas at rebertia.com
Mon Jul 16 04:03:54 CEST 2012
On Sat, Jul 14, 2012 at 11:18 PM, Đinh Nho Nam <namdn at socbay.com> wrote:
> Hi Python Software Foundation!
> I have learned Python for 2 years, and I love this language very much. The structure and grammar are simple and beautiful. I used this language in most of my projects.
> Now, I learn to use generator. This architecture is very intelligent. It allows programmer can pause and resume function. I think that this feature is not supported in classic language as C++, Java, C#.. In my design, we use 1 generator in both tasks: invoke and callback when download one url. But I have a small problem when getting instance of generator. How can I get own instance of generator in itself code?
<snip>
> How can we do as this code. How can I get self variable?. Does the language support this feature? I cannot find it in any document in python.org.
<snip>
> Can you add this feature in the next version of python???
Given that PEP 3130 (http://www.python.org/dev/peps/pep-3130/ ), which
would have similarly added nice ways to get the current module, class,
and regular function, was rejected, I wouldn't hold out much hope for
such a feature being added any time soon.
(Wrapping via decorators introduces nontrivial subtlety regarding
whether you really want to refer to the decorated or undecorated
version of an entity.)
Cheers,
Chris
More information about the Python-ideas
mailing list