If I make a function call check('list')
and in the function that I'm defining, which is called check, I want to use if isinstance(value, x):
where x is the argument of check, currently 'list'
but it may be any variable type, is there a simple way to use list
instead of 'list'
?
Asked
Active
Viewed 31 times
0

Cheese
- 401
- 1
- 4
- 7
1 Answers
0
Same as this.
typemap = {
'list': list
...
}
def check(x):
...
if isinstance(value, typemap[x]):
...
But really you should just be passing list
directly.

Community
- 1
- 1

Ignacio Vazquez-Abrams
- 776,304
- 153
- 1,341
- 1,358
-
Uh, no. You would index it as you would any other dictionary. Just as I have shown. – Ignacio Vazquez-Abrams Aug 24 '15 at 04:33