Deal with relative and absolute path : My script should open file properly whether it gets relative or absolute path as an argument.

There is something shorter and better that this my try?

   
    def main():
        if os.path.isabs(sys.argv[1]):
                filename = sys.argv[1]
        else:
                dir = os.path.dirname(__file__)
                filename = os.path.join(dir, sys.argv[1])
    
        assert os.path.exists(filename)
        print(filename) # or whatever I want to do with the path..

 
