python

Testing Your Code with Python's pytest, Part II

Testing functions isn't hard, but how do you test user input and output? In my last article, I started looking at "pytest", a framework for testing Python programs that's really changed the way I look at testing. For the first time, I really feel like testing is something I can and should do on a regular basis; pytest makes things so easy and straightforward.

Testing Your Code with Python's pytest

Don't test your code? pytest removes any excuses. Software developers don't just write software; they also use software. So, they're the first to recognize, and understand, that software is complex and inevitably contains bugs.

Automate Sysadmin Tasks with Python's os.walk Function

Using Python's os.walk function to walk through a tree of files and directories. I'm a web guy; I put together my first site in early 1993. And so, when I started to do Python training, I assumed that most of my students also were going to be web developers or aspiring web developers. Nothing could be further from the truth. Although some of my students certainly are interested in web applications, the majority of them are software engineers, testers, data scientists and system administrators.

Weekend Reading: Python

Python is easy to use, powerful, versatile and a Linux Journal reader favorite. We've round up some of the most popular recent Python-related articles for your weekend reading. Introducing PyInstaller by Reuven M. Lerner: Want to distribute Python programs to your Python-less clients? PyInstaller is the answer. Bytes, Characters and Python 2 by Reuven M. Lerner: Moving from Python 2 to 3? Here's what you need to know about strings and their role in in your upgrade. Introducing Python 3.7's Dataclasses by Reuven M. Lerner: Python 3.7's dataclasses reduce repetition in your class definitions. Examining Data Using Pandas by Reuven M. Lerner: You don't need to be a data scientist to use Pandas for some basic analysis. Multiprocessing in Python by Reuven M. Lerner: Python's "multiprocessing" module feels like threads, but actually launches processes.

Bytes, Characters and Python 2

Moving from Python 2 to 3? Here's what you need to know about strings and their role in in your upgrade. An old joke asks "What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American."

Introducing Python 3.7's Dataclasses

Python 3.7's dataclasses reduce repetition in your class definitions. Newcomers to Python often are surprised by how little code is required to accomplish quite a bit. Between powerful built-in data structures that can do much of what you need, comprehensions to take care of many tasks involving iterables, and the lack of getter and setter methods in class definitions, it's no wonder that Python programs tend to be shorter than those in static, compiled languages.

Python and Its Community Enter a New Phase

On Python's BDFL Guido van Rossum, his dedication to the Python community, PEP 572 and hope for a healthy outcome for the language, open source and the computing world in general. Python is an amazing programming language, there's no doubt about it. From humble beginnings in 1991, it's now just about everywhere. Whether you're doing web development, system administration, test automation, devops or data science, odds are good that Python is playing a role in your work.

Introducing PyInstaller

Want to distribute Python programs to your Python-less clients? PyInstaller is the answer. If you're used to working with a compiled language, the notion that you would need to have a programming language around, not just for development but also for running an application, seems a bit weird. Just because a program was written in C doesn't mean you need a C compiler in order to run it, right?

Examining Data Using Pandas

You don't need to be a data scientist to use Pandas for some basic analysis. Traditionally, people who program in Python use the data types that come with the language, such as integers, strings, lists, tuples and dictionaries. Sure, you can create objects in Python, but those objects typically are built out of those fundamental data structures.

ONNX: the Open Neural Network Exchange Format

An open-source battle is being waged for the soul of artificial intelligence. It is being fought by industry titans, universities and communities of machine-learning researchers world-wide. This article chronicles one small skirmish in that fight: a standardized file format for neural networks. At stake is the open exchange of data among a multitude of tools instead of competing monolithic frameworks.

Multiprocessing in Python

Python's "multiprocessing" module feels like threads, but actually launches processes. Many people, when they start to work with Python, are excited to hear that the language supports threading. And, as I've discussed in previous articles, Python does indeed support native-level threads with an easy-to-use and convenient interface.

Using Python for Science

Introducing Anaconda, a Python distribution for scientific research. I've looked at several ways you could use Python to do scientific calculations in the past, but I've never actually covered how to set up and use Python itself in a way that makes scientific work easier. Anaconda does just that.

Visualizing Molecules with Python

Introducing PyMOL, a Python package for studying chemical structures. I've looked at several open-source packages for computational chemistry in the past, but in this article, I cover a package written in Python called PyMOL.