[Biopython-dev] [Bug 3046] PhyloXML, please define get/set methods
bugzilla-daemon at portal.open-bio.org
bugzilla-daemon at portal.open-bio.org
Tue Apr 6 23:20:13 UTC 2010
http://bugzilla.open-bio.org/show_bug.cgi?id=3046
------- Comment #5 from joelb at lanl.gov 2010-04-06 19:20 EST -------
(In reply to comment #3)
>
> I don't understand what you are trying to do in this example, but a method
> called set_property seems wrong - are you trying to do something using
> property attributes for new-style Python classes?
>
> Also why are you using a list comprehension if you care about the side
> effects (creating a property)? Why not just use a for loop?
>
> Peter
>
There have long been built-in get/sets in python via __setattr__() and
__getattribute__(). That's where the code I sent should live. Putting code to
get and especially to set in those methods means that a user doesn't have to
look up whatever classes were defined for attributes (e.g. like finding that
'color' is called 'BranchColor') and doesn't need to know that taxonomies and
properties are only set through appending through lists.
The reason why to use a list comprehension rather than a for loop is
performance and readability. Small functions that work over a single item of a
sequence are vectorizable, either as list comprehensions or through
numpy.vectorize. See Ziade's "Expert Python Programming" p. 34. I have code
examples where the difference is a factor of 300 in speed.
I'm including an example code that I wrote. Feel free, Eric, to use it on the
PhyloXML page if you wish.
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Biopython-dev
mailing list