I would use `splitext` instead of replace given that this could remove anything thats `.pdf` and you really only want to remove the extension right?

```python
In [1]: from os.path import splitext

In [2]: h = '/home/wwwuser/git/qiime_web_app/www/americangut/img/results/000000001.pdf'

In [3]: splitext(h)
Out[3]: 
('/home/wwwuser/git/qiime_web_app/www/americangut/img/results/000000001',
 '.pdf')

In [4]: splitext(h)[0]
Out[4]: '/home/wwwuser/git/qiime_web_app/www/americangut/img/results/000000001'

```