On 06/27/2013 12:33 PM, Matt D wrote:
<SNIP>
I forgot to mention i have the 'with open(mypath, "a") as f: commented
out because it was making an indentation error that i could not fix.
It was indented, and should not have been. The extra indentation
FOLLOWS the with statement, it's not correct to indent the line itself.
Line it up with mypath=
Isn't the rule for indentation simple enough? If a line ends with a
colon, you indent the next line. And keep indenting till the scope of
that colon ends. I don't know of any exceptions, but if there are any,
they're rare. Anyway, when the compiler complains, there aren't many
choices on how to change the line, so experimentation should teach you
pretty quickly.
Maybe you're getting confused about indentation because your editor
doesn't handle tabs correctly. If you mix tabs and spaces, you'll drive
yourself crazy, at least with 2.x Python 3 tells you about it with a
new error. The easy answer (and my strong preference) is to never use
tabs in Python sources. Expand all your existing tabs (to 4 column
intervals), and tell your editor to always expand the tab key when
entering.
I suggest you fix this problem first, and understand the fix, before
going off and using shutil.copy().
Thanks! I do have 'with open(mypath, "a") as f:' lined up with the
mypath line above (not sure why it indented with the paste to email) and
I already replaced all tabs with spaces. seriously there is not one
single tab in the whole program. but when that line is not commented out
the program bails with the indentation error, other wise its fine. .
So i don't know what i can do about that.
Thanks!
What text editor are you using? Can you literally move the cursor one
column at a time and see what column each of those two lines are in?
It's a little hard to imagine your email program converting all those
spaces to tabs.
If it were my file, and I got to this point, I'd be using a dump program
to look at the actual file. Or I'd configure my text editor for
40-column tabs, to make them very visible and very obnoxious.
In Linux, use tweak, or any of dozens of others. Likewise there are
lots in Windows -- no idea what one to suggest.
--
DaveA
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor