How to determine whether specified file is placed inside of the specified folder?
<p>Let's say I have two paths: the first one (may be file or folder path): <code>file_path</code>, and the second one (may only be a folder path): <code>folder_path</code>. And I want to determine whether an object collocated with <code>file_path</code> is inside of the object collocated with <code>folder_path</code>.</p>

<p>I have an idea of doing this:</p>

<pre><code>import os
...
def is_inside(file_path, folder_path):
  full_file_path   = os.path.realpath(file_path)
  full_folder_path = os.path.realpath(folder_path)
  return full_folder_path.startswith(full_file_path)
</code></pre>

<p>but I'm afraid there are some pitfalls in this approach. Also I think there must be a prettier way to do this.</p>

<p>The solution must work on Linux but it would be great if you propose me some cross-platform trick.</p>
