[Biopython-dev] Using .format() method of strings in Biopython?
Carlos Pena
mycalesis at gmail.com
Tue Oct 13 11:17:10 UTC 2015
Hi,
There is the PEP3101 https://www.python.org/dev/peps/pep-3101/ where:
"This PEP proposes a new system for built-in string formatting
operations, intended as a replacement for the existing '%' string
formatting operator."
It may be better to avoid conflicting styles in the code and avoid using
the format method at all. But Python seems to be evolving fast and maybe
Biopython should keep up.
carlos
On 13.10.2015 14:03, Peter Cock wrote:
> Dear Biopythoneers,
>
> As part of https://github.com/biopython/biopython/pull/635
> Carlos is suggesting replacing some of the % string formatting
> (which is like the C sprintf function) with the Python string .format()
> method.
>
> e.g.
>
> "Codon '%s' is invalid" % codon
>
> becomes:
>
> "Codon '{0}' is invalid".format(codon)
>
> https://pyformat.info/
> https://docs.python.org/2/library/string.html#formatstrings
> https://docs.python.org/2/library/stdtypes.html#string-formatting
>
> Note the later says the following about the .format method:
>
> "This method of string formatting is the new standard in Python 3"
>
> We don't have anything explicit about this on our current short
> coding conventions entry on the wiki:
>
> http://biopython.org/wiki/Contributing#Coding_conventions
>
> Right now usage of the format method is rare (e.g. Bio.codonalign
> and Bio.motifs.jaspar)
>
> Should we be encouraging more use of the format method?
>
> Is there a more explicit PEP standard we can cite for this
> preference?
>
> Peter
>
More information about the Biopython-dev
mailing list