On this page
posixpath.getsize
Prev: posixpath.getmtime | Up: posixpath | Next: posixpath.isabs
Rel: posixpath.abspath, posixpath.basename, posixpath.commonpath, posixpath.commonprefix
Ref: docs.python.org — posixpath.getsize
Tags: #public #python3 #stdlib #posixpath
Import
import posixpath
from posixpath import getsize
Signature & Overview
posixpath.getsize(filename)
Return the size of a file, reported by os.stat().
Usage
import posixpath
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as tmp:
p = Path(tmp) / 'x.bin'
p.write_bytes(b'123')
assert posixpath.getsize(p) == 3
Gotchas
- Returns file size in bytes.
REPL Inspect
from posixpath import getsize
help(getsize)
Linked from
Related notes
- tuts/python3/stdlib_module/posixpath/getmtime Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/isabs Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/posixpath/abspath Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/basename Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonpath Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonprefix Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/dirname shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/exists shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/expanduser shared tags: #posixpath, #stdlib