Python Forum
how to test if an object came from os.walk()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to test if an object came from os.walk()
#1
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

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.
Reply


Messages In This Thread
how to test if an object came from os.walk() - by Skaperen - Jan-09-2018, 02:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Smile Python & MSGraph - Learning to Walk ITMan020324 2 435 Feb-04-2024, 04:37 PM
Last Post: ITMan020324
  EasySNMP Walk/BulkWalk pylance 3 2,114 Nov-29-2021, 12:00 PM
Last Post: pylance
  How to test and import a model form computer to test accuracy using Sklearn library Anldra12 6 3,192 Jul-03-2021, 10:07 AM
Last Post: Anldra12
  How to sort os.walk list? Denial 6 11,652 Oct-10-2020, 05:28 AM
Last Post: Denial
  os.walk question DPaul 2 2,358 May-31-2020, 02:08 PM
Last Post: DPaul
  os.walk(Path("path_string")) giving error Kumarkv 4 3,902 May-10-2020, 08:46 AM
Last Post: snippsat
  How to write test cases for a init function by Unit test in python? binhduonggttn 2 3,149 Feb-24-2020, 12:06 PM
Last Post: Larz60+
  How to write test cases by Unit test for database configuration file? binhduonggttn 0 2,579 Feb-18-2020, 08:03 AM
Last Post: binhduonggttn
  os.walk does not see files that are in the folder kiton 1 3,051 Jan-21-2020, 07:26 PM
Last Post: micseydel
  print notifcation when enter new directory os.walk() evilcode1 3 2,642 Jun-20-2019, 08:19 PM
Last Post: evilcode1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020