Skip to content

Instantly share code, notes, and snippets.

View eloraburns's full-sized avatar

Elora Burns eloraburns

View GitHub Profile
@eloraburns
eloraburns / gist:786091
Created January 19, 2011 12:18
Random bit flipping
# Assuming Python >=2.5, <3.0
import os
from random import randint
num_random_bits = 9
with open('f', 'r+') as f:
f.seek(0, os.SEEK_END)
length = f.tell()-1
for _ in range(num_random_bits):
place = randint(0, length)
f.seek(place, os.SEEK_SET)