Python "aha" moment

G

Guy Middleton

I wanted to decode some MIME base64 text, and had no program that does this,
so I thought it must be easy to do in Python.

I have been using Python, on and off, for a long time, so I used a file idiom
I remembered from years ago:

for line in sys.stdin:
sys.stdout.write(base64.decodestring(line))


This works fine, but then I realised that the language has evolved since then,
and I could make this more obviously a transformation:

base64.decode(sys.stdin, sys.stdout)


I like this version much better.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top