You should use `not directory.endswith('.sagenb')`, I believe.