Python Forum
isinstance() arg2 is limited to a type or a tuple of types
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
isinstance() arg2 is limited to a type or a tuple of types
#1
isinstance() arg2 is limited to a type or a tuple of types. it won't even accept a list of types.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
I always use isinstance when I want to identify a particular type, not a range of types.
Reply
#3
what do you mean by "not a range of types"?

1. you use something else for a range of type.

2, you never do a range of types.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
2. I rarely need it. When programming, I think binary.
Reply
#5
Any practical reason to supply container of container of types? It's either single type or multiple types in which case container (e.g. list, tuple, etc.) of types is enough. Just unpack your nested structure.

Sorry, I misread the question
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
i coded this:
def istype(a,b):
    x=type(a)
    return x is b or x in b
in this function, arg2 can be any container type supported by the RHS of in.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  optimizing calls to isinstance() Skaperen 0 842 Nov-27-2022, 01:33 AM
Last Post: Skaperen
  isinstance() vs type() Skaperen 3 2,571 Oct-13-2019, 06:25 AM
Last Post: Gribouillis
  math.gcd() is limited to 2 arguments Skaperen 2 3,940 Aug-10-2019, 01:00 AM
Last Post: Skaperen
  Distributed size limited queue implementation? johsmi96 1 1,923 May-08-2019, 07:29 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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