[Biopython] [Entrez.efetch] save records

Peter Cock p.j.a.cock at googlemail.com
Fri Dec 4 16:16:41 UTC 2015


On Fri, Dec 4, 2015 at 3:53 PM,  <c.buhtz at posteo.jp> wrote:
> On 2015-12-04 08:33 Peter Cock <p.j.a.cock at googlemail.com> wrote:
>> (Slightly off topic, do you care about Python 3.3? Maybe we
>> can drop support for that and get ride of this ugly-handle-hack
>> workaround)
>
> I am not sure what you mean. Can you explain please?

There are some bugs in Python 3 (fixed in Python 3.4 onwards)
to do with text handles. In order to cope with this Biopython has
an internal class EvilHandleHack. The name was meant to suggest
this is a short term temporary solution.

Once we drop support for Python 3.3, we can get rid of this
internal class EvilHandleHack. For more information, see:

https://github.com/biopython/biopython/blob/fd893554fe343985429da69d5e107d6ee96766be/Bio/_py3k/__init__.py#L94

> I use the current Python3.x available on my system: v3.4.
> I don't care about Python2 not because it is "old" (Python3 is "old",
> too). Because it is "better" in some points and most packages
> supporting it.

Good.

> And by the way: Python2 is quite different in syntax. I am not able to
> write anything in Python2 because I don't know it.
>
>> Thet returned object is just a (wrapper for) a normal handle,
>
> I know that.
>
>>         output_handle.write(results_handle.read())
>
> I would never thought like that. ;) To easy.

This will load the entire file into memory as one big string, then
write it out again to the output handle. You could also do this
gradually, e.g. line by line:

for line in results_handle:
    output_handle.write(line)

I'm glad this is working for you now though.

Peter


More information about the Biopython mailing list