Python Forum
detecting a generstor passed to a funtion
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
detecting a generstor passed to a funtion
#1
what is the appropriate pythonic way for a function to detect that a generator is passed to it? i can do this:
if type(arg).__name__=='generator':
    print('got a generator')
else:
    print('did not get a generator')
i cannot do:
if isinstance(arg,generator):
    print('got a generator')
else:
    print('did not get a generator')
because generator is not defined.
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
detecting a generstor passed to a funtion - by Skaperen - Sep-19-2021, 12:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to receive two passed cmdline parameters and access them inside a Python script? pstein 2 339 Feb-17-2024, 12:29 PM
Last Post: deanhystad
  iterating and detecting the last Skaperen 3 1,067 Oct-01-2022, 05:23 AM
Last Post: Gribouillis
  Detecting float or int in a string Clunk_Head 15 4,478 May-26-2022, 11:39 PM
Last Post: Pedroski55
  module detecting if imported vs not Skaperen 1 1,669 Nov-19-2021, 07:43 AM
Last Post: Yoriz
  Python BLE Scanner not detecting device alexanderDennisEnviro500 0 2,002 Aug-01-2021, 02:29 AM
Last Post: alexanderDennisEnviro500
  how to modify a variable that is passed as parameter StefanL38 2 2,111 Dec-07-2020, 08:39 AM
Last Post: StefanL38
  Detecting power plug Narayan 2 2,701 Aug-01-2020, 04:29 AM
Last Post: bowlofred
  Detecting USB Device Insertion on Windows 10 Atalanttore 0 2,377 Jan-17-2020, 02:46 PM
Last Post: Atalanttore
  are numeric types passed by value or reference? rudihammad 4 2,616 Nov-19-2019, 06:25 AM
Last Post: rudihammad
  Detecting windows shutdown event riccardoob 4 5,702 Nov-12-2019, 04:51 PM
Last Post: Aurthor_King_of_the_Brittons

Forum Jump:

User Panel Messages

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