[Biopython-dev] GSoC code+documentation review: PhyloXML for Biopython
Eric Talevich
eric.talevich at gmail.com
Sat Jul 4 13:24:12 EDT 2009
On Sat, Jul 4, 2009 at 12:39 PM, Peter <biopython at maubp.freeserve.co.uk>wrote:
> On Sat, Jul 4, 2009 at 5:28 PM, Eric Talevich<eric.talevich at gmail.com>
> wrote:
> > On Sat, Jul 4, 2009 at 10:14 AM, Peter <biopython at maubp.freeserve.co.uk
> >wrote:
> >
> >>
> >> The __repr__ thing isn't Biopython specific, its just what Python does.
> For
> >> simple objects, eval(repr(obj)) should recreate the object. Consider:
> >>
> >> >>> print phx.other
> >> [Other(tag=alignment, namespace=http://example.org/align)]
> >>
> >> That is odd to me. It looks like "other" is a list, containing an
> "Other"
> >> object, but with a funny __repr__ - I would have expected it to look
> more
> >> like this:
> >>
> >> >>> print phx.other
> >> [Other(tag="alignment", namespace="http://example.org/align")]
> >>
> >> i.e. using the repr of what I have assumed are string arguments.
> >>
> >> Peter
> >>
> >
> > Hi Peter,
> >
> > Thanks! Your interpretation of the example is correct. I'll change
> __repr__
> > to check if the attribute is a string and, if so, escape and quote it.
>
Correction: since it's filtering for primitive types already, I'll just call
repr() on each attribute.
I changed the wiki page examples to show this, and I'll fix the code on
Monday.
>
> If you can do it without risking a really long string, this is a good
> idea. You'll notice the Seq object repr actually uses a truncated
> sequence for long sequences - you won't want to accidentally
> get the whole thing printed at the python prompt! Likewise
> doing repr() on a SeqRecord doesn't give you the full object.
>
> Peter
>
OK, I'll add another check for long strings and truncate them like Seq does.
This isn't in the wiki examples yet, though.
-Eric
More information about the Biopython-dev
mailing list