title: python, read specific characters of filenames
body: <p>I want to open a list of filenames and keep as strings specific parts of the filenames.</p>
  
  <p>in a bash file (run.sh) I have the following code</p>
  
  <pre><code>shopt -s nullglob
  
  for path in $emiss_data/*; do    
    if [[ -f "$path" ]]; then
      filename=$(basename "$path")
      echo "processing $filename"
    fi
    ....
  done
  </code></pre>
  
  <p>with the above code the whole name of filename is read (e.g. poll_test.txt)</p>
  
  <p>I want to read for example as a string the "poll" (first 4 characters) and as a seperate string the filename without the extension (i.e. exceeding the last 3 characters).</p>