File Attributes conversion

Martin von Loewis loewis at informatik.hu-berlin.de
Mon Mar 4 07:35:23 EST 2002


sam_collett at lycos.co.uk (Sam Collett) writes:

> e.g.
> File Size to display in bytes (if < 3kb), kilobytes (if < 2MB) and
> megabytes (> 2MB). How would you do that (the value I get is 12345L -
> what is the L?)

It indicates that that Python value was a 'long' integer (one that can
exceed 4GB); you best format format these with %d

> Modified/Created time to be displayed as GMT (DD mm YYYY, HH MM am/pm)
> 14/09/2002, 5:54pm (is it in seconds currently [starting from which
> year]?)

You can use time.strftime for that.

> I am doing this on Windows 98SE, is it possible to get the code to
> work cross platform as well?

As long as it is file sizes and time stamps, yes, certainly.

> PS Can you also get other attributes (read-only, hidden, compressed,
> system, archive, etc)?

I think you need to use the Win32 extensions for these, since they are
Microsoft-specific.

Regards,
Martin




More information about the Python-list mailing list