I don't think "anomaly" is quite the right word, as it happens *reliably*.
It is an effect of ( I was about to say side effect, but it well may
be intentional ) the code objects that python code is compiled into:
>>> def one():
... return 1
...
>>> one.func_code.co_consts
[None, 1]
>>>
I assume that what this means is that "return 1" really becomes
something more (pseudo-) like "return code.co_consts[1]", and so
>>>if id(1) == id(1) :
really becomes: if id(co_consts[1]) == id(co_consts[1])
[ Obviously, not quite literally - this is my pseudo-python
representation of my guess at the compiled .pyc code
representation, which is probably quite inaccurate in
detail, but, in the context of explaining id(1)==id(1),
if probably close enough.
I was peeking around at the code-object representation back
in the thread about self documenting functions to see if the
args were available somewhere. I haven't had quite the time
to decipher it in enough detail to understand WHAT exactly
is the use and structure of those code attributes structures. ]
- Steve