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