python

Understanding Python's asyncio

How to get started using Python's asyncio. Earlier this year, I attended PyCon, the international Python conference. One topic, presented at numerous talks and discussed informally in the hallway, was the state of threading in Python—which is, in a nutshell, neither ideal nor as terrible as some critics would argue.

DNA Geometry with cadnano

This article introduces a tool you can use to work on three-dimensional DNA origami. The package is called cadnano, and it's currently being developed at the Wyss Institute. With this package, you'll be able to construct and manipulate the three-dimensional representations of DNA structures, as well as generate publication-quality graphics of your work.

An AI Wizard of Words

A look at using OpenAI's Generative Pretrained Transformer 2 (GPT-2) to generate text. It's probably fair to say that there's more than one person out there who is worried about some version of artificial intelligence, or AI, possibly in a robot body of some kind, taking people's jobs. Anything that is repetitive or easily described is considered fair game for a robot, so driving a car or working in a factory is fair game.

Python's Mypy--Advanced Usage

Mypy can check more than simple Python types. In my last article, I introduced Mypy, a package that enforces type checking in Python programs. Python itself is, and always will remain, a dynamically typed language. However, Python 3 supports "annotations", a feature that allows you to attach an object to variables, function parameters and function return values. These annotations are ignored by Python itself, but they can be used by external tools.

Build Your Own Internet Radio Receiver

Tune in to communities around the world with the push of a button. When I get home at night, I like to tune into the world with the push of a button. I've lived in lots of different places—from Dunedin, New Zealand, to Santa Fe, New Mexico—and in each town, I've come to love a radio station (usually a community radio station) that embodies the spirit of the place. With the push of a button, I can get a bit back in sync with each of these places and also visit new communities, thanks to internet radio.

Easier Python paths with pathlib

A look at the benefits of using pathlib, the "object-oriented way of dealing with paths". Working with files is one of the most common things developers do. After all, you often want to read from files (to read information saved by other users, sessions or programs) or write to files (to record data for other users, sessions or programs).

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?