>>816
with open(filename, 'r') as f:
text = f.read()

# textを使った処理

と書けば普通にreadしてメモリに読み込んでファイルは閉じられる。
CとかC++とか、JavaとかC#でも一緒じゃない?