Need instruction on how to use isinstance

S

Steven W. Orr

I need to test an argument for a few different types.

I'm calling my function like this

arf = MyFunc(list)

What I want to do is to test for whether something is a string, tuple, list or
function. It's that last one that's causing me a problem.

if isinstance(arg, (str, tuple, list)):

No problem, but there are a lot of types that the type function returns. If I
have a simple function

def foo():
pass
type(foo)
prints out
<type 'function'>

So, my question is, what value can I use as the 2nd arg to isinstance to see if
foo is a function? And while I'm on the subject, what types does isinstance not
support?

And last, what is the correct way to do it if this is not the right way?

TIA (and hoping I'm clear)

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,664
Latest member
Phil79581

Latest Threads

Top