strncmp in python
<p>I am parsing through a file with a list of paths. I am trying to see if one path is under a specific directory or not. So I have two strings S1 and S2. Lets say they are 
S1 = '/tmp/' and S2 = '/tmp/file.txt'</p>

<p>If I want to check if is S2 has S1 and then some extra bytes in C, I would do a strncmp of S1 and S2 upto strlen(S1) bytes. Is there a way to do that in python? I am new to python and do not know all the modules available to me yet. I could implement this trivially by just iterating over the characters in the strings and comparing, but want to find out if there is anything that gives me these kind of helper functions by default</p>

<p>Thanks for any help. </p>

<p>P</p>
