News for hackers. Stuff that matters.
Re:When being idiomatic wears you out by nraynaud on Saturday August 27, 2011 @09:38AM (#2931432)
I actually had the converse experience yesterday.

I digged into python File nonsense trying to find a size() method, and the best explanation I got is that File doesn't have a size() method because it's not meant to designate a file but a strange mix of input/output stream/reader/writer. And since you can't really navigate into python code, I had to google quite a lot to get this explanation.

Best part of the story ? Actually I use django and it has a sane File class with a size() on it, just that it's not appearing in google when you don't send the right request (and IO is pyhton base stuff, not web stuff in my head, so I didn't put the django keyword).

Re:When being idiomatic wears you out by krakensden on Saturday August 27, 2011 @01:20PM (#2931938)
The file protocol is for generic streams, but you could seek to the end and then call tell().

If you just want to know the size of a file and don't want to write to it, os.stat() will do what you want.

Re:When being idiomatic wears you out by clownz0r on Monday September 05, 2011 @06:21AM (#2961783)
Perhaps I'm misunderstanding what you wanted to do, but is there a reason you can't use os.path.getsize?

http://docs.python.org/library/os.path.html#os.path.getsize