I have learned to change lead into gold, and back again, for real! Well, sort of. Thus far, it only works within the virtual world of programming languages like Python. Here is the recipe. (If you are not into geek-speak, skip to the bottom where I natter on about reading ebooks on an iPad.)
class Lead(object): def prestoChango(self): self.__class__ = Gold class Gold(object): def prestoChango(self): self.__class__ = Lead pb = Lead() print pb # prints Lead pb.prestoChango() print pb # prints Gold pb.prestoChango() print pb # prints Lead
Voila! First it’s lead. Then it’s gold. Then it’s lead again.
I understand why you might want to do something like this but, at least within the projects that I work on, it would obfuscate the program too much for my liking.
I learned this from reading the Python Coookbook ebook on my iPad, which has been thoroughly enjoyable. I like the iBooks app more than I expected to. I can highlight portions of the book, without actually trashing the pages. I can scribble notes next to my highlights. I can easily browse a list of the sections that I highlighted/noted. Perhaps even more useful, I can select a word or phrase from the text of the book and instantly search either Google or Wikipedia for it.