Packaging for Python App

Posted on Fri 23 March 2018 in articles

It is not quite convenient for our customer to setup Python environment on Windows or other platforms to run our Python app. So we need to pack our Python app into stand-alone .exe file. Fortunately, there are quite a few tools to help us. And among these, PyInstaller is my …


Continue reading

Charset Handling in Python

Posted on Tue 13 March 2018 in articles

As we know, Python 3 treats all string using UTF-8, and it is great. Sometimes, we need to unzip some zip files which come from Windows machine.

# Unzip the zipfile to a folder.
zf = zipfile.ZipFile(zipped_file_full_path)

for name in zf.namelist():
    # FIXME: Need to handle path string encoding.
    new_name …

Continue reading

Protobuf in Python

Posted on Tue 13 March 2018 in articles

Protobuf is a method to serializing structured objects. It helps to develop applications which are communicating with each other over a wire. protoc is the code generator by reading the .proto files and it provides Python support.

First, we will need to install the Protocol Buffers compiler protoc. In macOS …


Continue reading

Image Processing in Python

Posted on Mon 12 March 2018 in articles

PIL is the Python Imaging Library by Fredrik Lundh and Contributors. Pillow is the friendly PIL fork by Alex Clark and Contributors. We can use Pillow to processing image, e.g., adding watermark to an image.

from PIL import Image, ImageDraw, ImageFont

# Add watermark to the image.
image = Image.open …

Continue reading

Sending Mail in Python

Posted on Mon 12 March 2018 in articles

We need to send mails sometimes, e.g. report sending service. email module in Python will work this for us.

from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate

def send_mail(server, port, account, password …

Continue reading

Python Anywhere

Posted on Sun 11 March 2018 in articles

I write this post to mark down some useful Python resources.

Full Stack Python - The right place to learn everything you need to create, deploy and operate production Python web applications.

Awsome Python - A curated list of awesome Python frameworks, libraries, software and resources.

MicroPython - MicroPython is a lean and …


Continue reading

Python 2 or Python 3

Posted on Sun 11 March 2018 in articles

If you ask me which Python version should be used, Python 2 or Python3?

My answer is: Python 3 absolutely!

Python 2.7 Countdown


Continue reading

First Post

Posted on Sat 10 March 2018 in articles

This is my first post and I did it in Python. How exciting!

This website is generated by Pelican and using theme Flex.

For code highlighting, I choose PYGMENTS_STYLE = 'solarized-dark', with a minor change that I add .highlight { font-size: 0.9em } to make highlighted code's font size a little smaller …


Continue reading