#135: Date and Time in Python (Part 2: Datetime)
After a deeper look at date last week, we explore in this post the datetime and time objects of Python.
After a deeper look at date last week, we explore in this post the datetime and time objects of Python.
I waited a long time to address date and time because that topic has the potential to get complicated quickly. In a side project I needed some date arithmetic and that is a good opportunity to look at date and time in Python.
I needed to return multiple values from a function. While Python allows that with tuples, it is a lot of magic involved and the meaning in the order of values in the tuple is nowhere written down. Is there a better way to create a data transfer object without much effort? Let's find out.
Your terminal applications do not need to have a boring output. Today we take a look at how we can create nice looking tables without much effort.
Since I concluded my experiments with Tweepy in April, a new and important Twitter endpoint finally arrived: Bookmarks. Let's have a look how we can access our Twitter bookmarks with Tweepy.
While Python works great on Linux, Windows and Mac, there are tiny differences that may have big impacts on your code. I found this out the annoying way with a crashing application.
For some problems it would be great if our application could access the clipboard of the current user and do some copy & paste actions. Let's look how we can access the clipboard from Python.
If you need to run a task every few seconds or create a report every week, you can use Celery and its feature for periodic tasks – at least if we use Linux or WSL on Windows.
So far our Celery tasks where fire-and-forget jobs. We put a task in a queue and go to the next activity. However, sometimes we need to know if a task succeeded before we can do more work. Let us take a look on how Celery tracks tasks.
Flask is a great web framework. The only problem, as with all web applications, is the processing of long-running tasks. Luckily for us, we can use our knowledge of Celery and combine it with Flask to process the long-running tasks asynchronously. Even better, we already know everything we need to do this.