title: Python 2.7: get the size of a file just from its handle (and not its path)
body: <p>I am writing a function that needs to do things on a file, based on the file-size (in bytes). I would like to minimize the number of parameters to pass to the function, so I would only pass the handle to the already-open file, and let the function get the size.
  Is there an elegant way to do this?</p>
  
  <p>I was trying the following, with <code>os.path.getsize(os.path.abspath(file_id))</code>, but it doesn't work:</p>
  
  <pre><code>def datafile_profiler(file_id):
      filesize = os.path.getsize(os.path.abspath(file_id))
  
      #[...] continue doing things with the file, based on the size in bites
  
      return stuff
  </code></pre>
  
  <p>and then, from the "main code"</p>
  
  <pre><code>file_id = open(filepath, "rb")
  stuff = datafile_profiler(file_id)
  file_id.close()
  </code></pre>
  
  <p>Any suggestion (also a totally different approach) is welcome.
  Thaks.</p>