Jan-09-2018, 02:35 AM
i am writing a function that is to be given an object that came from os.walk(). i like to do thorough error checks in code i write, at least for final release. os.walk() returns a generator. is there a way to be more specific and detect that the given object is a generator from os.walk() as opposed to some other kind of generator? should i even be trying to do this and, instead, allow callers to pass a generator that looks and quacks like a generator from os.walk()?
how would you go about testing for just a generator, since
how would you go about testing for just a generator, since
isinstance(foo,generator)does not work, because generator is not defined. is there something i can import to get this definition, or should i just do
isinstance(foo,type(os.walk()))?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.