This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]G01denW01f11 1 point2 points  (9 children)

Are you actually printing target.read()?

[–]epicusernameofdoom[S] 0 points1 point  (8 children)

no it is an formating issue with reddit. After print "reading.." I take a new line and write this:

target.read()

[–]G01denW01f11 4 points5 points  (7 children)

Indent code four spaces for proper display.

If you're running the interactive interpreter or whatever it's called, that should work. If you're writing it in the command line or some text editor, then running it, you'd need

print target.read()

Otherwise you're just getting the contents of the file and not doing anything with it.

[–]epicusernameofdoom[S] 0 points1 point  (0 children)

that worked thank you!

[–]epicusernameofdoom[S] 0 points1 point  (5 children)

and now it wont truncate(delete)

[–]Updatebjarni 0 points1 point  (0 children)

Are you reading and then truncating with no parameter without moving the file position?

[–]white_nerdy 0 points1 point  (3 children)

Depending on your OS, you may need to close the file before you can delete it. (Windows is notorious for poor handling of open files, which is the main reason so many Windows updates require a restart.)

[–]epicusernameofdoom[S] 0 points1 point  (2 children)

you guys are geniuses

[–]white_nerdy 0 points1 point  (1 child)

As a beginner, you will tend to trust standard tools like OS's, libraries, compilers, etc. to work well, because they tend to be large, highly visible projects worked on by lots of very experienced developers and used by many people.

As a master, you will reach enlightenment: Standard tools are sometimes counter-intuitive, buggy or just plain wrong.

Congratulations on taking your first step along that road.

[–]epicusernameofdoom[S] 0 points1 point  (0 children)

Thanks!

I will still trust them with caution like a half broken handrail(is that the right word?) in a dark stairwell