473,395 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Format file size for printing

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?

Feb 19 '06 #1
2 2773
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?

Feb 20 '06 #2

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

Feb 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as...
3
by: marwa mohamed | last post by:
salamo alikom hi all when i run report that includes image control linked to a field in the table that contains the image path(on the server)and the record source of the report contains over 30...
6
by: Larry R Harrison Jr | last post by:
I have Access XP, and the following code which is supposed to assign a JPEG to an image control: Me.Image9.Picture = "F:\Pictures\CP775_SonyDSCP50\FingerRockNight_Resize.jpg" I get this error...
3
by: Melissa | last post by:
What specifically causes the Format event of a report's section to fire? Thanks! Melissa
5
by: bcanavan | last post by:
When I export xml(and xls) from Access 2003 the result is a complete report in a single page. I would like to get the entire report in a single page (one trip to the server) for printing and...
1
by: Raymond Du | last post by:
Hi, I have serveral web forms used by users, these users often use IE browser print function to print out the form, the problems I have is what users see on the screen is usually different from...
6
by: coriolis_wong | last post by:
Hi, I need to transfer csv format file to DBase III format file. How do i do it in Python language? Any help is appreciated. Thanks.
5
by: ChinChin | last post by:
Hi, I have made a window application that get file information from the server the file size return in bytes. I need help on how to format the file size accordingly so that it will return the file...
2
by: necron99 | last post by:
import RuntimeEnvironment as renv import os, sys import win32com.client import getpass OMI = win32com.client.Dispatch("MOVEitAPI.clientObj") OMI.Host = system
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.