From b909043eeee55544efe530525e6f16f8208f46be Mon Sep 17 00:00:00 2001 From: Jordi Date: Sat, 18 Nov 2023 11:14:37 +0100 Subject: [PATCH] tree.pyx: Nicer representation of Tree objects. More in line with other Python objects when they are asked for their repr(). Now a Tree looks like: --- ete4/core/tree.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ete4/core/tree.pyx b/ete4/core/tree.pyx index 093a05c80..832d79b59 100644 --- a/ete4/core/tree.pyx +++ b/ete4/core/tree.pyx @@ -268,7 +268,8 @@ cdef class Tree(object): return True def __repr__(self): - return 'Tree %r (%s)' % (self.name, hex(self.__hash__())) + name_str = (' ' + repr(self.name)) if self.name else '' + return '' % (name_str, hex(self.__hash__())) def __getitem__(self, node_id): """Return the node that matches the given node_id."""