Re: class destruction (evil genius metaprogramming)
by Giles Bowkett other posts by this author
Jun 18 2007 11:05AM messages near this date
Re: class destruction (evil genius metaprogramming)
|
lose the first character
> > >> I do sometimes wonder what would happen if the ancestry array were
> > >> writeable. It could be interesting. I haven't thought through the
> > >> possible pitfalls.
...
> Would you want to be able to switch ordering too? I wonder what kind
> of interesting evil could come of that...
You can play with this in Python. If you modify the __class__ magic
var you can change an object's class in real-time. When I first
discovered this, I posted on a Python list that it seemed like a
sportscar without a seatbelt, and got some very outraged responses
from Python programmers who felt passionately that it was one of the
language's best features. The most memorable response turned my words
around ("sportscar without a speed limit").
On the flipside, I also heard a story from a guy who found this kind
of thing heavily abused in some legacy bioinformatics code in Python,
and he was not happy about it. Objects would wander off into
particular methods and come back home completely transformed. It
sounded very confusing.
--
Giles Bowkett
Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org
Thread:
Giles Bowkett
Rick DeNatale
dblack
Robert Dober
dblack
Robert Dober
Giles Bowkett
dblack
Stephen Smith
Nathan Taylor-Hoover
Giles Bowkett
dblack
Giles Bowkett
Rick DeNatale
dblack
Devin Mullins
dblack
Gregory Brown
Giles Bowkett
|