Skip to content

Commit

Permalink
tree.pyx: Nicer representation of Tree objects.
Browse files Browse the repository at this point in the history
More in line with other Python objects when they are asked for their repr().

Now a Tree looks like:

<Tree "A" at 0x4343432>
  • Loading branch information
jordibc committed Nov 18, 2023
1 parent 3b6d762 commit b909043
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ete4/core/tree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<Tree%s at %s>' % (name_str, hex(self.__hash__()))

def __getitem__(self, node_id):
"""Return the node that matches the given node_id."""
Expand Down

0 comments on commit b909043

Please sign in to comment.