I think @timothymh is right, this is a Python question not a Textwrangler one, but regardless, to open a file with Textwrangler:
via the Finder
Just double click it. If that file type is associated with a different application then open the context menu for the file, and select "Get Info" and change the "Open with:" to Textwrangler. Click the "Change All…" if you want all files of that type to open in Textwrangler.
via the Terminal
With Textwrangler open and active, select the Textwrangler menu and "Install Command Line Tools". This will give you the
edit command, so to open a text file in Documents called "My Text File.txt" you'd issue the command via the terminal of:
edit ~/Documents/My\ Text\ File.txt
and it will open in Textwrangler.
Now that's out the way…
The Python problem
You're trying to open a file without giving the full path to the file. Since you don't give a full path (either absolute or relative) the command assumes it's a relative file path, which means it will look for "genomic_dna.txt" in the current working directory.
You've also not specified a file mode, which means
open will assume you want to read the file. All of which means you get an error, because that file does not exist in the current working directory.
To fix this, either:
- Give an absolute path, e.g.
file = open("/Users/jonathan/Documents/genomic_dna.txt") (or wherever genomic_dna.txt is to be found, obviously).
- Give a relative path, e.g. if the current working directory is
file = open("../Documents/genomic_dna.txt").
- If the file doesn't exist because you haven't created it yet and want to write to it, then pass the file mode, e.g.
file = open("genomic_dna.txt", "w").
You might want to try using the Python interpreter to test your code out first and then transfer it to a file (by using Textwrangler to save it). To open the interpreter just type
python at a terminal and press enter.