Here’s a snippet of code to sneak into someone’s .pythonrc if you want them to hate you:
import sys
from numpy import *
class Evil:
size = array(1).itemsize
__array_interface__ = {
'shape' : (1,),
'typestr' : '<i%d'%size,
'data' : (id(1)+2*size, 0) }
asarray(Evil())[0] = 2
assert 1 == 2
It’s even platform independent! (Note: it will be less innocuous if the class isn’t named Evil.)