Python Coding Guideline Tooling Unit Testing and Packages
Python Coding Guideline Tooling Unit Testing and Packages : The course covers intermediate and advanced Python programming techniques.
This means that the course is not intended for programming beginners.
However, you do not have to be a senior software engineer, you just should know about the basics in Python.
â— Variables and primitive data types
â— Boolean logic and conditions/comparisons
â— Wiriting own and using extern functions and classes
â— Working with pip and external packages (importing)
â— Python installed on your computer (for example with Anaconda)
The Course covers the following Topics:
â˜‘ï¸ Creating a Python environment tailored for the course (virtualenv or anaconda env)
â˜‘ï¸ Installing and setting up the most used Python IDE: Visual Studio Code (vscode)
â˜‘ï¸ The coding guidelines and good practice programming (PEP8)
â˜‘ï¸ The usage of Pylint, Flake8, Autopep8, Black and Pydocstyle
â˜‘ï¸ Different docstring styles for your code (sphinx, numpy and google)
â˜‘ï¸ The usage of type annotations and the static type checker MyPy
â˜‘ï¸ The usage of debugging, profiling, execution time measuring (timing) and unit testing (TDD)
â˜‘ï¸ The creation of own Python packages that can be uploaded to PyPi
â˜‘ï¸ The creation of a modern HTML documentation with mkdocs and google docstrings
â˜‘ï¸ The usage of continouos integration tools (github actions for testing and codedoc)
My first experience with coding was using S-Plus (a forerunner to R) as an undergraduate statistics student. Our lecturer, a professor with decades of experience, taught us how to fit regression models by literally typing our code one line at a time into the S-Plus console.
If you wanted to be able to re-run your code at a future point in time, you could save it in a text file and then cut and paste it into the console.
It wasn’t until years later, in my third job after graduation, and after completing a PhD in Statistics, that I first discovered programming scripts, and what good code actually looks like.
Looking back, I’m astounded this situation ever occurred. However, from talking to my data scientist friends, particularly those who don’t come from a software developer background, it appears my situation is not unique.
It is an unfortunate fact that many data scientists do not know how to write production-quality code.
Production-quality code is code that is:
- Free from errors;
- Robust to exceptions;
- Well documented; and
Producing it is not rocket science.
Anyone smart enough to be able to understand neural networks and support vector machines (i.e. most data scientists) is certainly capable of learning good coding practices.
The problem is that most data scientists don’t even realize that writing production-quality code is something they can and should learn.
How to Write Production-Quality Code
In my article 12 Steps to Production-Quality Data Science Code, I outline, in detail, a simple process data scientists can follow to make their code production ready.
In summary, the steps are:
- Determine what you’re trying to achieve;
- Build a minimum viable product;
- Reduce repetition using the DRY principle;
- Create and run unit tests;
- Deal with exceptions;
- Maximize time and space efficiency;
- Make variable and function names meaningful;
- Check your code against a style guide;
- Ensure reproducibility;
- Add comments and documentation;
- Ask for a code review; and
For many of these steps, there are no real short cuts to be taken. The only way to build a minimum viable product, for example, is to roll up your sleeves and start coding. However, in a few cases, tools exist to automate tedious manual processes and make your life much easier.
In Python, this is the situation for steps 4, 8 and 10, thanks to the unittest, flake8 and sphinx packages.
Let’s look at each of these packages one by one.
Automate Your Error Checks with unittest
Unit tests are used to ensure that the functions that make up your code are doing what they should be doing, under a range of different circumstances.
If your code only contains a small number of relatively straight forward functions, then you probably only need a handful of unit tests, which you can feasibly run and check manually.
Step ahead in your Python career an join this course!
I hope will see you there âœŒ
Python Coding Guideline Tooling Unit Testing and Packages Python Programming Python Coding Python Packages Coursera Free Courses Udemy free Courses Download Free Online Course
What you’ll learn
The Coding guidelines and good practice programming (PEP8)
Tooling with Pylint, Flake8, Autopep8, Black etc.
Type Annotations and Mypy
The usage of Debugging, Profiling, Timing and Unit Testing
The creation of own Python packages
The creation of a modern HTML documentation
The usage of continouos integration tools
Who this course is for:
- (Junior) Python developer who want to master the language
- Be able to work with your operating system and the terminal
- You should know the Python basics (Variables, Functions, Classes etc.)
Last Updated 1/2021