file size different readings on linux and python3












0















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.



enter image description here



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



enter image description here










share|improve this question



























    0















    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.



    enter image description here



    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



    enter image description here










    share|improve this question

























      0












      0








      0








      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.



      enter image description here



      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



      enter image description here










      share|improve this question














      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.



      enter image description here



      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



      enter image description here







      linux python3






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 2 at 0:42









      kutluskutlus

      686




      686






















          1 Answer
          1






          active

          oldest

          votes


















          2














          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).



          enter image description here



          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.







          share|improve this answer
























          • Oh, thank you, I thought they are different comparing with kilobytes!

            – kutlus
            Feb 2 at 1:02











          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          2














          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).



          enter image description here



          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.







          share|improve this answer
























          • Oh, thank you, I thought they are different comparing with kilobytes!

            – kutlus
            Feb 2 at 1:02
















          2














          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).



          enter image description here



          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.







          share|improve this answer
























          • Oh, thank you, I thought they are different comparing with kilobytes!

            – kutlus
            Feb 2 at 1:02














          2












          2








          2







          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).



          enter image description here



          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.







          share|improve this answer













          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).



          enter image description here



          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.








          share|improve this answer












          share|improve this answer



          share|improve this answer










          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



















          • 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


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          How to make a Squid Proxy server?

          Is this a new Fibonacci Identity?

          19世紀