0

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

Cheese
  • 401
  • 1
  • 4
  • 7

1 Answers1

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