Topic: deleting a folder within a folder

I've got multiple branches in the company folder and then multiple users per branch. I need to remove certain users as they leave a branch. I don't get an error but the entire branch folder gets deleted and not just the specified user folder. Can someone point me in the right direction

#!/usr/bin/python
import os, sys, getopt, shutil
branch, user = "",""

if __name__ == "__main__":
    argv = sys.argv[1:]
    try:
       opts, args = getopt.getopt(argv, 'hd:e', ['help', 'branch=', 'user='])
    except getopt.GetoptError:
       print __doc__
       sys.exit()

    for opt, arg in opts:
       if opt in ('-h', '--help'):
           print __doc__
           sys.exit()
       if opt in ('-d', '--branch'):
           branch = arg
       if opt in ('-e', '--user'):
           user = arg

shutil.rmtree("/home/company/%s/%s" % (branch , user))

Thumbs up

Re: deleting a folder within a folder

I have tested it on python 2.7 - that's all right
construct and print the path before the call

Thumbs up