Anna
Anna

Reputation: 121

Voodoo Code In Python

I was going through Zed Shaw's Learn Python The Hard Way and something in Chapter 15 struck me. In the extra credit exercises he asks us to delete the latter part of the code [everything after print txt.read() ] and then execute it, but the interpreter behaves as if nothing has happened. Yes, I saved the file and when I modified it by adding print statements then the changes still showed up, but the same voodoo code was executed. Why?

What's going on over here?

from sys import argv

script, filename = argv

txt = open(filename)

print "Here's your file %r:" % filename
print txt.read()

print "I'll also ask you to type it again:"
file_again = raw_input("> ")

txt_again = open(file_again)

print txt_again.read()

Upvotes: 2

Views: 586

Answers (1)

Lennart Regebro
Lennart Regebro

Reputation: 172279

You are probably executing a different file then the one you are editing.

Upvotes: 1

Related Questions