[Biopython-dev] [Bug 2561] SeqRecord format method to get a string	in a given file format
    bugzilla-daemon at portal.open-bio.org 
    bugzilla-daemon at portal.open-bio.org
       
    Sat Aug  2 08:43:46 EDT 2008
    
    
  
http://bugzilla.open-bio.org/show_bug.cgi?id=2561
------- Comment #8 from biopython-bugzilla at maubp.freeserve.co.uk  2008-08-02 08:43 EST -------
Regarding the __format__ method, see this thread on the dev-mailing list in
June:
http://lists.open-bio.org/pipermail/biopython-dev/2008-June/003816.html
This suggests something like this could be used to support the format()
function in Python 2.6/3.0:
def __format__(self, format_spec=None):
    """Format the SeqRecord into a string.
    This method supports the python format() function added in
    Python 2.6/3.0.  The format_spec should be a lower case
    string supported by Bio.SeqIO as an output file format.
    See also the to_format() method."""
    if format_spec:
        return self.to_format(format_spec)
    else :
        #Follow python convention and default to using __str__
        return str(self)
[And similar for the Alignment object]
We can add this new method without causing any problems for older versions of
Python, as they will ignore the new method.
-- 
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