<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Python on Chris Hager</title><link>https://www.metachris.dev/tags/python/</link><description>Recent content in Python on Chris Hager</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Mon, 12 Apr 2021 00:00:00 +0000</lastBuildDate><atom:link href="https://www.metachris.dev/tags/python/index.xml" rel="self" type="application/rss+xml"/><item><title>PDFx update and new version release (v1.4.1)</title><link>https://www.metachris.dev/2021/04/pdfx-update-and-new-version-release-v1.4.1/</link><pubDate>Mon, 12 Apr 2021 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2021/04/pdfx-update-and-new-version-release-v1.4.1/</guid><description>&lt;hr>
&lt;p>&lt;a href="https://github.com/metachris/pdfx">PDFx&lt;/a> is a tool to extract text, links, references and metadata from PDF files and URLs. Thanks to &lt;a href="https://github.com/metachris/pdfx/graphs/contributors">several contributors&lt;/a> the project received a thorough update and was brought into 2021. The new release of today is &lt;a href="https://pypi.org/project/pdfx/">PDFx v1.4.1&lt;/a> &amp;#x1f389;&lt;/p>
&lt;p>PDFx works like this:&lt;/p></description></item><item><title>MicroPython-Ctl - a TypeScript library for talking to MicroPython devices</title><link>https://www.metachris.dev/2021/01/micropython-ctl-a-typescript-library-for-talking-to-micropython-devices/</link><pubDate>Fri, 29 Jan 2021 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2021/01/micropython-ctl-a-typescript-library-for-talking-to-micropython-devices/</guid><description>I&amp;rsquo;m happy to introduce MicroPython-Ctl: a TypeScript library for talking to MicroPython devices (such as ESP32/8266, Raspberry Pi Pico, Pyboard, WiPy, and many more).
Use micropython-ctl to quickly build apps that interact with MicroPython devices: Websites / webapps, Node.js programs, Electron applications, Visual Studio Code extensions, Mobile apps (eg. with React Native) and more.
Connect to devices over serial or network interface Run Python scripts, receive the output Manipulate files and directories Terminal (REPL) interaction mctl command-line utility Mount MicroPython devices locally (with FUSE, experimental) Typed and fully async (you can use await with any command).</description></item><item><title>A new version of logzero is released (v1.6) 🎉</title><link>https://www.metachris.dev/2020/10/a-new-version-of-logzero-is-released-v1.6/</link><pubDate>Fri, 30 Oct 2020 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2020/10/a-new-version-of-logzero-is-released-v1.6/</guid><description>logzero is a simple and effective logging library for Python, with colored stream output, logfile, syslog, JSON formatting and much more: https://github.com/metachris/logzero
After a really busy period with my second 🐣, I start to find a little bit of time here and there for fun projects. Recently I&amp;rsquo;ve enjoyed a few evenings maintaining logzero, culminating in a small release today: logzero v1.6 🎉
logzero v1.6 has several improvements:
JSON formatting (with integrated python-json-logger) Easily change colors to custom color codes Allow creating of root loggers Allow file logging with lower loglevel than stream Project readme and history was converted to markdown and displays nicely on PyPI Deprecation of Travis CI Running tests with GitHub Actions, with Python versions up to 3.</description></item><item><title>logzero - Simplified logging for Python 2 and 3</title><link>https://www.metachris.dev/2017/06/logzero-simplified-logging-for-python-2-and-3/</link><pubDate>Thu, 29 Jun 2017 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2017/06/logzero-simplified-logging-for-python-2-and-3/</guid><description>I&amp;rsquo;ve just published logzero, a small Python package which simplifies logging with Python 2 and 3. It is easy to use and robust, and heavily inspired by the Tornado web framework. I&amp;rsquo;ve recently released python-boilerplate.com which included this module as a file, and people have been asking for it to be published as a standalone package. Finally I&amp;rsquo;ve found some time to do it, and here it is!
https://logzero.readthedocs.io https://github.com/metachris/logzero logzero is a simple and effective logging module for Python 2 and 3:</description></item><item><title>Python Utilities by Peter Norvig</title><link>https://www.metachris.dev/2016/12/peter-norvigs-python-utilities-advent-of-code/</link><pubDate>Tue, 27 Dec 2016 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2016/12/peter-norvigs-python-utilities-advent-of-code/</guid><description>Peter Norvig, the famous American computer scientist and Director of Research at Google Inc., participated in this year&amp;rsquo;s Advent of Code (a series of small programming puzzles), and shared his experience in an interesting blog post.
The post starts with this amazing collection of Python utility functions, which may also be useful for your next project:
# Python 3.x import re import numpy as np import math import urllib.request from collections import Counter, defaultdict, namedtuple, deque from functools import lru_cache from itertools import permutations, combinations, chain, cycle, product from heapq import heappop, heappush def Input(day): &amp;#34;Open this day&amp;#39;s input file.</description></item><item><title>Python Thread Pool</title><link>https://www.metachris.dev/2016/04/python-threadpool/</link><pubDate>Mon, 11 Apr 2016 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2016/04/python-threadpool/</guid><description>A thread pool is a group of pre-instantiated, idle threads which stand ready to be given work. These are often preferred over instantiating new threads for each task when there is a large number of (short) tasks to be done rather than a small number of long ones.
Suppose you want do download 1000s of documents from the internet, but only have resources for downloading 50 at a time. The solution is to utilize is a thread pool, spawning a fixed number of threads to download all the URLs from a queue, 50 at a time.</description></item><item><title>How to install Qt 5.6 and PyQt5 in a Python 3.4 virtual environment on Mac OS X and Linux</title><link>https://www.metachris.dev/2016/03/how-to-install-qt56-pyqt5-virtualenv-python3/</link><pubDate>Thu, 24 Mar 2016 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2016/03/how-to-install-qt56-pyqt5-virtualenv-python3/</guid><description>This is a simple guide on installing the latest Qt (currently 5.6) and PyQt5 on Mac OS X 10.11 (El Capitan) and Linux with Python 3.4, inside a virtual environment.
Installation Steps
Python 3 Xcode and command-line tools Qt libraries Virtual environment SIP Python package PyQt5 Python package Python 3 First of all, make sure that Python 3 is available on your system. You can easily check this by opening the terminal and entering the command python3.</description></item><item><title>Find broken hyperlinks in a PDF document with PDFx</title><link>https://www.metachris.dev/2016/03/find-broken-hyperlinks-in-a-pdf-document-with-pdfx/</link><pubDate>Sat, 19 Mar 2016 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2016/03/find-broken-hyperlinks-in-a-pdf-document-with-pdfx/</guid><description>PDFx is a free command-line tool to extract references, links and metadata from PDF files. You can also use it to find broken links in a PDF file, using pdfx -c:
For each URL and PDF reference, pdfx performs a HEAD request and checks the status code. It there are broken links, PDFx print the link with the page number where the link was found in the original pdf:
$ pdfx https://weakdh.</description></item><item><title>Creating standalone Mac OS X applications with Python and py2app</title><link>https://www.metachris.dev/2015/11/create-standalone-mac-os-x-applications-with-python-and-py2app/</link><pubDate>Sat, 28 Nov 2015 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2015/11/create-standalone-mac-os-x-applications-with-python-and-py2app/</guid><description>In this tutorial we&amp;rsquo;ll be using py2app to create a standalone OSX application from a Python 2 or 3 source code with a simple Tkinter user interface.
"py2app is a Python setuptools command which will allow you to make standalone application bundles and plugins from Python scripts. py2app is similar in purpose and design to py2exe for Windows." Relevant links about py2app:
Documentation Source on BitBucket (last commit 2015-05-05) Issue Tracker, Mailing List This guide is loosely based on the official tutorial.</description></item><item><title>Python Helpers for String/Unicode Encoding, Decoding and Printing</title><link>https://www.metachris.dev/2015/11/python-tools-for-string-unicode-encoding-decoding-printing/</link><pubDate>Mon, 23 Nov 2015 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2015/11/python-tools-for-string-unicode-encoding-decoding-printing/</guid><description>String encoding and decoding as well as encoding detection can be a headache, more so in Python 2 than in Python 3. Here are two little helpers which are used in PDFx, the PDF metadata and reference extractor:
make_compat_str - decode any kind of bytes/str into an unicode object print_to_console - print (unicode) strings to any kind of console (even windows with cp437, etc.) All of this code is in the public domain via The Unlicense.</description></item><item><title>David Beazley - Python Concurrency From the Ground Up (LIVE @PyCon 2015)</title><link>https://www.metachris.dev/2015/11/david-beazley-python-concurrency-from-the-ground-up-live-pycon-2015/</link><pubDate>Fri, 13 Nov 2015 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2015/11/david-beazley-python-concurrency-from-the-ground-up-live-pycon-2015/</guid><description>Great talk and engaging live coding session &amp;ldquo;Python Concurrency From the Ground Up&amp;rdquo; by David Beazley at PyCon 2015! Recommended 47 minutes watch.
A few selected quotes:
The fact that he walked in and did this demo from scratch while keeping the packed room engaged was incredible.﻿ A more comprehensive quote:
David Beazley's 2015 PyCon talk on concurrency was one of my favorite talks of the conference, and it was almost all just live coding.</description></item><item><title>PDFx v1.0 - Extract metadata and URLs from PDFs, and download all referenced PDFs</title><link>https://www.metachris.dev/2015/10/pdfx-extract-metadata-and-download-references-from-pdfs/</link><pubDate>Mon, 26 Oct 2015 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2015/10/pdfx-extract-metadata-and-download-references-from-pdfs/</guid><description>I just released PDFx version 1.0, a Python tool and library to extract metadata and URLs from PDFs, and to automatically download all referenced PDFs. The project is released under the Apache license with the source code on Github!
Features Extract metadata and PDF URLs from a given PDF (file or URL) Download all PDFs referenced in the original PDF Works with local and online pdfs Use as command-line tool or Python package Compatible with Python 2 and 3 Quick Start Grab a copy of pdfx with easy_install or pip and run it:</description></item><item><title>App Engine Boilerplate 2.0 – Using html5-boilerplate v2 on Google App Engine</title><link>https://www.metachris.dev/2011/08/app-engine-boilerplate-2-0-using-html5-boilerplate-v2-on-google-app-engine/</link><pubDate>Fri, 12 Aug 2011 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2011/08/app-engine-boilerplate-2-0-using-html5-boilerplate-v2-on-google-app-engine/</guid><description>Just a year ago Paul Irish and several contributors started working on html5-boilerplate, a popular repository of boilerplate and best practices for creating cross-browser compatible, html5-enabled websites. Thanks to the efforts of many front-end developers and researchers who have spent countless hours on developing and evolving best practices, html5 boilerplate is rapidly maturing and establishing itself as the de-facto standard html boilerplate.
The authors just celebrated the one-year anniversary with the release of version 2.</description></item><item><title>App Engine Boilerplate</title><link>https://www.metachris.dev/2011/04/app-engine-boilerplate/</link><pubDate>Tue, 05 Apr 2011 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2011/04/app-engine-boilerplate/</guid><description>I recently started appengine-boilerplate, a repository of often used boilerplate code for Google&amp;rsquo;s App Engine, which allows to quickly setup new projects without having to re-invent the most common wheels. All code is released under the BSD license, and It comes with the following goodies:
html5-boilerplate (incl. jQuery) OpenID authentication User preferences data model (with gravatar image link) Memcache for datastore objects Handlers for /, /profile, /login and /logout Custom template tags Various tools such as is_testenv(), decode(input) and slugify(title) app.</description></item><item><title>Scaling Python Servers with Worker Processes and Socket Duplication</title><link>https://www.metachris.dev/2011/01/scaling-python-servers-with-worker-processes-and-socket-duplication/</link><pubDate>Sat, 29 Jan 2011 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2011/01/scaling-python-servers-with-worker-processes-and-socket-duplication/</guid><description>Developing servers that scale is usually quite tricky, even more so with Python and the absence of worker threads which can run on multiple cpu cores [1]. A possible solution are worker processes that duplicate the client’s socket, a technique that allows the workers to processes requests and send responses directly to the client socket. This approach is particularly useful for long lasting connections with more than one request per session.</description></item><item><title>Unicode and UTF Overview</title><link>https://www.metachris.dev/2010/12/unicode-overview/</link><pubDate>Mon, 27 Dec 2010 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2010/12/unicode-overview/</guid><description>This post is a brief technival overview of Unicode, a widely used standard for multilingual character representation, and the family of UTF-x encoding algorithms. First a brief introduction to Unicode:
Unicode is intended to address the need for a workable, reliable world text encoding.
Unicode could be roughly described as &amp;ldquo;wide-body ASCII&amp;rdquo; that has been stretched to 16 bits to encompass the characters of all the world&amp;rsquo;s living languages. In a properly engineered design, 16 bits per character are more than sufficient for this purpose.</description></item><item><title>Python, Threads and the Global Interpreter Lock (GIL)</title><link>https://www.metachris.dev/2010/10/python-threads-and-the-global-interpreter-lock-gil/</link><pubDate>Wed, 13 Oct 2010 00:00:00 +0000</pubDate><guid>https://www.metachris.dev/2010/10/python-threads-and-the-global-interpreter-lock-gil/</guid><description>This post is about Python, Threads, Multiprocessing, the GIL, and a great talk by David Beazley titled &amp;ldquo;Inside the Python GIL&amp;rdquo;.
Threads Threads make it possible to execute multiple pieces of code in parallel, which means either utilizing multiple processors or having the operating system schedule execution time for the threads sequentially on one processor. In contrast to multiprocessing (forking) where multiple separated processes are started, all threads run in a single process and have access to the same resources.</description></item></channel></rss>