Is there a way to subclass a generator in Python 3? -
Clearly, I thought I'd try it, just in case:
Def sulfin (input = none): ... yield ... gpt = type (somgin ()) class subdivision (gtepe): def best_function_ass (): ...
sorry The response to Python was quite unfavorable:
"Type error: type generator is not an acceptable base type"
will be in the form of fate, this is a The problem is meLook, I was thinking that maybe it would happen to play with a fun base type, if I gave it a chance. Imagine my surprise! ..and frustration is there any way to see things in the way of the omnipotent path?
This is definitely a binary question outside, so please do not say that it is not possible that you can not think immediately in a way Python (especially PE3) is very flexible.
Of course, if you have proof that why not ("should not be") is not the base type (P3), then I do Want to see and understand
You can not make a generator subclass using this yield
A function is defined as, but you can use it in any other generator.
Just take it simple:
def alphagen (N = 27): If n & lt; 0 or n> 27: N = For the category I (n): yield CRR (ord ('A') + i)
You get:
& Gt; & Gt; & Gt; & Gt; [A for Algegen (10)] ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
You can reset it to Alfagan (N): resul + = I generate a resonance
and now you get: />
gt; & Gt; [One for Alfertartan (8)] ['A', 'AB', 'ABC', 'ABCD', 'ABCDE', 'ABCDEF', 'ABCDEFG', 'ABCDFGH]]
Comments
Post a Comment