Add %python magic to history