Getting started with TinyGo and WebAssembly (WASM)

Posted on Fri 23 October 2020 in Development • Tagged with go, golang, tinygo, web, webassembly, wasm, assembly, js, javascript, html, browser, macos, code, development, embedded, programming, language

This tutorial explains how to call a method written in Go and compiled to WebAssembly (WASM) from JavaScript by using TinyGo


Continue reading

Python 3.9 introduces removeprefix and removesuffix

Posted on Sun 11 October 2020 in Development • Tagged with python, development, python39, programming, version, language, strings, manipulation

A quick tutorial to removeprefix and removesuffix methods which have been introduced with Python 3.9.0


Continue reading

Using pyenv to install Python and create a virtual environment

Posted on Sat 10 October 2020 in Development • Tagged with python, development, pyenv, virtualenv, mkvirtualenv, environment, python39, programming, pip, macos, install, version

How to use pyenv to install a specific version of Python and create a virtual environment with that version


Continue reading

Skipping tests depending on the Python version

Posted on Thu 21 February 2019 in Python • Tagged with python, test, programming, software, development, testing

Sometimes we want to run certain tests only on a specific version of Python.

Suppose you are migrating a large project from Python 2 to Python 3 and you know in advance that certain tests won't run under Python 3.

Chances are that during the migration you are already using the six library. The six libraries have two boolean properties which are initialised to True depending on the Python version which is being used: PY2 when running under Python 2 and PY3 when running under Python 3.

This library, combined with the skipIf method of unittest library can be used to easily skip tests when using Python 3:

import six
import unittest


class MyTestCase(unittest.TestCase):


    @unittest.skipIf(six.PY3, "not compatible with Python 3")
    def test_example(self):
        # This test won't run under Python 3
        pass

Credits

Thanks to my colleague Nicola for giving me the inspiration to write this post.