eval() of a __name__
Kevin Turner
kevinperson at topicbox.com
Fri Nov 2 03:49:37 EST 2001
I walked through compile
and eval'd myself,
wond'red if I had a name.
I looked at my __name__tag
and saw it said "__builtin__",
a problem apparent quite plain:
You looked for a __name__
in namespaces local;
Failing to locate,
you tried going global;
Found there some __builtins__,
a module named __builtin__,
in which you found me
a __name__.
No suprise that a __name__
in a module for built-ins
should be the string
"__builtin__" when read.
But I for one knew that
that was not *my* name --
what should they call me instead?
I consulted my friends,
the __str__ and the __repr__;
recommending brackets both ends.
Between them I'd put maybe a classname,
an identifier or two.
A key '__name__' in globals, a value of "<code.vals>",
with this I was sure I was through.
(...Phew!)
But as I did use it I grew more confuséd,
my imports behaving quite strange --
The keys to the values in system dot modules
had been given all the wrong names!
'import this.that' became "<code.this.that",
others similarly perturbed.
The effect of it was havoc in codeland:
my references -- all were disturbed!
Emperical testing shows that some __names__s are safer.
but to know which is which? I have no sure way for
telling between the two...
So tell me, list-python, what should I do?
--
The moon is waning gibbous, 99.4% illuminated, 15.5 days old.
More information about the Python-list
mailing list