file size different readings on linux and python3
I have some files in the terminal folder. As seen in the picture the size of the file is 33 kB, when I keep the mouse on it reads 33.88 kB.
However, when check the same file`s size using both os.stat and os.path I get a different number(in bytes). Where do I do wrong? Thanks
linux python3
add a comment |
I have some files in the terminal folder. As seen in the picture the size of the file is 33 kB, when I keep the mouse on it reads 33.88 kB.
However, when check the same file`s size using both os.stat and os.path I get a different number(in bytes). Where do I do wrong? Thanks
linux python3
add a comment |
I have some files in the terminal folder. As seen in the picture the size of the file is 33 kB, when I keep the mouse on it reads 33.88 kB.
However, when check the same file`s size using both os.stat and os.path I get a different number(in bytes). Where do I do wrong? Thanks
linux python3
I have some files in the terminal folder. As seen in the picture the size of the file is 33 kB, when I keep the mouse on it reads 33.88 kB.
However, when check the same file`s size using both os.stat and os.path I get a different number(in bytes). Where do I do wrong? Thanks
linux python3
linux python3
asked Feb 2 at 0:42
kutluskutlus
686
686
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
To make long story short, Python's os.stat()
outputs size in bytes. However, your file manager shows size in Kibibytes, which is a measure in powers of 2 instead of 10 as Kilobytes do (and because computer science for the most part uses powers of 2, while average consumers are more familiar with powers of 10).
To be more specific, Python's os.stat()
shows size depending on the type of file; to quote documentation:
The interpretation of “file size” changes according to the file type. For plain files this is the size of the file in bytes. For FIFOs and sockets under most flavors of Unix (including Linux in particular), the “size” is the number of bytes waiting to be read at the time of the call to os.stat(), os.fstat(), or os.lstat(); this can sometimes be useful, especially for polling one of these special files after a non-blocking open. The meaning of the size field for other character and block devices varies more, depending on the implementation of the underlying system call.
Oh, thank you, I thought they are different comparing with kilobytes!
– kutlus
Feb 2 at 1:02
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498233%2ffile-size-different-readings-on-linux-and-python3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
To make long story short, Python's os.stat()
outputs size in bytes. However, your file manager shows size in Kibibytes, which is a measure in powers of 2 instead of 10 as Kilobytes do (and because computer science for the most part uses powers of 2, while average consumers are more familiar with powers of 10).
To be more specific, Python's os.stat()
shows size depending on the type of file; to quote documentation:
The interpretation of “file size” changes according to the file type. For plain files this is the size of the file in bytes. For FIFOs and sockets under most flavors of Unix (including Linux in particular), the “size” is the number of bytes waiting to be read at the time of the call to os.stat(), os.fstat(), or os.lstat(); this can sometimes be useful, especially for polling one of these special files after a non-blocking open. The meaning of the size field for other character and block devices varies more, depending on the implementation of the underlying system call.
Oh, thank you, I thought they are different comparing with kilobytes!
– kutlus
Feb 2 at 1:02
add a comment |
To make long story short, Python's os.stat()
outputs size in bytes. However, your file manager shows size in Kibibytes, which is a measure in powers of 2 instead of 10 as Kilobytes do (and because computer science for the most part uses powers of 2, while average consumers are more familiar with powers of 10).
To be more specific, Python's os.stat()
shows size depending on the type of file; to quote documentation:
The interpretation of “file size” changes according to the file type. For plain files this is the size of the file in bytes. For FIFOs and sockets under most flavors of Unix (including Linux in particular), the “size” is the number of bytes waiting to be read at the time of the call to os.stat(), os.fstat(), or os.lstat(); this can sometimes be useful, especially for polling one of these special files after a non-blocking open. The meaning of the size field for other character and block devices varies more, depending on the implementation of the underlying system call.
Oh, thank you, I thought they are different comparing with kilobytes!
– kutlus
Feb 2 at 1:02
add a comment |
To make long story short, Python's os.stat()
outputs size in bytes. However, your file manager shows size in Kibibytes, which is a measure in powers of 2 instead of 10 as Kilobytes do (and because computer science for the most part uses powers of 2, while average consumers are more familiar with powers of 10).
To be more specific, Python's os.stat()
shows size depending on the type of file; to quote documentation:
The interpretation of “file size” changes according to the file type. For plain files this is the size of the file in bytes. For FIFOs and sockets under most flavors of Unix (including Linux in particular), the “size” is the number of bytes waiting to be read at the time of the call to os.stat(), os.fstat(), or os.lstat(); this can sometimes be useful, especially for polling one of these special files after a non-blocking open. The meaning of the size field for other character and block devices varies more, depending on the implementation of the underlying system call.
To make long story short, Python's os.stat()
outputs size in bytes. However, your file manager shows size in Kibibytes, which is a measure in powers of 2 instead of 10 as Kilobytes do (and because computer science for the most part uses powers of 2, while average consumers are more familiar with powers of 10).
To be more specific, Python's os.stat()
shows size depending on the type of file; to quote documentation:
The interpretation of “file size” changes according to the file type. For plain files this is the size of the file in bytes. For FIFOs and sockets under most flavors of Unix (including Linux in particular), the “size” is the number of bytes waiting to be read at the time of the call to os.stat(), os.fstat(), or os.lstat(); this can sometimes be useful, especially for polling one of these special files after a non-blocking open. The meaning of the size field for other character and block devices varies more, depending on the implementation of the underlying system call.
answered Feb 2 at 0:56
Sergiy KolodyazhnyySergiy Kolodyazhnyy
10.3k32662
10.3k32662
Oh, thank you, I thought they are different comparing with kilobytes!
– kutlus
Feb 2 at 1:02
add a comment |
Oh, thank you, I thought they are different comparing with kilobytes!
– kutlus
Feb 2 at 1:02
Oh, thank you, I thought they are different comparing with kilobytes!
– kutlus
Feb 2 at 1:02
Oh, thank you, I thought they are different comparing with kilobytes!
– kutlus
Feb 2 at 1:02
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498233%2ffile-size-different-readings-on-linux-and-python3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown