Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Format file size for printing

Reply
Thread Tools

Format file size for printing

 
 
abcd
Guest
Posts: n/a
 
      02-19-2006
is there a built-in way of printing the size of a file nicely?

So if the file size is 103803 bytes it prints out like: 103.8K
or
0.1MB

something liek that?

 
Reply With Quote
 
 
 
 
John Zenger
Guest
Posts: n/a
 
      02-20-2006
I know of no built-in way, but you could probably code this in a few
lines using print "%.1f" and so on.

(Some of us, by the way, are in the camp that believes a kilobyte is
1024 bytes, not 1000, so 103803 bytes for us is about 101.4 kilobytes).

abcd wrote:
> is there a built-in way of printing the size of a file nicely?
>
> So if the file size is 103803 bytes it prints out like: 103.8K
> or
> 0.1MB
>
> something liek that?
>

 
Reply With Quote
 
 
 
 
Fuzzyman
Guest
Posts: n/a
 
      02-20-2006

abcd wrote:
> is there a built-in way of printing the size of a file nicely?
>
> So if the file size is 103803 bytes it prints out like: 103.8K
> or
> 0.1MB
>
> something liek that?


Pathutils (small extension module - not builtin) contains a basic
function that does this.

http://www.voidspace.org.uk/python/pathutils.html

All the best,


Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:52 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:50 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:28 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-18-2007 10:11 AM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM



Advertisments