whatis expression Print the type of the argument.
(self, arg)
| 2275 | self.message(s + '\t' + line.rstrip()) |
| 2276 | |
| 2277 | def do_whatis(self, arg): |
| 2278 | """whatis expression |
| 2279 | |
| 2280 | Print the type of the argument. |
| 2281 | """ |
| 2282 | if not arg: |
| 2283 | self._print_invalid_arg(arg) |
| 2284 | return |
| 2285 | try: |
| 2286 | value = self._getval(arg) |
| 2287 | except: |
| 2288 | # _getval() already printed the error |
| 2289 | return |
| 2290 | code = None |
| 2291 | # Is it an instance method? |
| 2292 | try: |
| 2293 | code = value.__func__.__code__ |
| 2294 | except Exception: |
| 2295 | pass |
| 2296 | if code: |
| 2297 | self.message('Method %s' % code.co_name) |
| 2298 | return |
| 2299 | # Is it a function? |
| 2300 | try: |
| 2301 | code = value.__code__ |
| 2302 | except Exception: |
| 2303 | pass |
| 2304 | if code: |
| 2305 | self.message('Function %s' % code.co_name) |
| 2306 | return |
| 2307 | # Is it a class? |
| 2308 | if value.__class__ is type: |
| 2309 | self.message('Class %s.%s' % (value.__module__, value.__qualname__)) |
| 2310 | return |
| 2311 | # None of the above... |
| 2312 | self.message(type(value)) |
| 2313 | |
| 2314 | complete_whatis = _complete_expression |
| 2315 |
nothing calls this directly
no test coverage detected