Metaprogramming question

Travis Griggs travisgriggs at
Tue Feb 11 19:13:31 CET 2014

The discussion about niladic functions, made me want to follow a segue and do some reflection/introspective programming in Python. I’ve not done a lot of that yet, and it seemed like an educational (well, at least entertaining) goose chase.

If I run the following code:

import datetime, 42)

I will get an error (expected). The error I will get is:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: now() takes at most 1 argument (2 given)

So, at some point, there’s some metadata in the system attached to the builtin method, that indicates 1 argument, tops.

So here’s my basic question. Is there anyway to programatically query that information in python code?


just gives a ValueError. inspect must only be good for the python code that I write, in python. Is there another way to dig out what the interpreter knows there?

More information about the Python-list mailing list