The first thing we have to do is build a mock data set that…
Lately, I’ve been exploring the asynchronous world and primarily the asyncio library and stumble across an interesting finding. Most of the async stuff going on is based on Coroutines, Future objects, Generators and much more. Since I am a guy who loves to dig deeper into stuff I decided to explorer Python generators and how they are related to the async world.
First things first. What is a generator. A generator is a special class of functions that simplify the task of writing iterators. Regular functions compute a value and return it, but generators return an iterator that returns a…
In a previous article, we built a contact application where users can submit their requests via a form on the website. Just as a reminder here is how the form looks like.
When a user submits the form it gets verified and saved by Django’s
form_valid() method. By utilizing this method, as well as
form_invalid() we can send different notification emails to regular users, admins depending on which method is trigger after form submission. In addition to regular information that could be sent via email (such as the user submitting the form, his/her email, subject, and actual message) we are…
In the last article, I have covered the basics of setting up a Django project. In this article, I am going to cover something that many people underestimate and that is the Model View Controller Framework that Django relies on. Even though most people know it as MVC framework, Django uses a slightly different approach and the actual framework that is being used is Model View Template. One area of Django that most people are missing is how requests are actually handled and what is the information flow.
A model is the single, definitive source of information about data. It…
Asyncio is also something to be considered also but the point of the article was elsewhere. asyncio is not trully asynchronous because all tasks are executed in an synchonous manner. It appears to be async because tasks are switching between each other when on wait.
I am about to publish another article for asyncio and I have decided not to include it here.
In the last article, I have covered the basics of setting up a Django project. In this article, we are going to create a simple contact application that will help our users to contact us.
The first thing to do is to create the application itself. That pretty easy thing to do and Django provides a tool for it. Do not forget to activate your virtual environment before application creation.
$ python manage.py startapp contact
When you create a Django application you get a folder similar to this one.
This is the first in a series of articles in which we are going to build a portfolio application where you can showcase yourself and your work. We are going to cover important topics and I will try to explain each of them in a separate article. This series of articles will mainly focus on the Django development side of things. If you are interested in the front-end, I may write a couple of articles explaining that part of the application. …
In this article we are going to take a closer look at Twitter API (Application Programming Interface) and how can we use it to retrieve tweets based on certain criteria. This article assumes that you have a basic knowledge of Python and APIs. For those who are new to the world of software development here is a quick reminder.
In computing, an application programming interface (API) is an interface that defines interactions between multiple software applications or mixed hardware-software intermediaries. It defines the kinds of calls or requests that can be made, how to make them, the data…
Recently, I have been working on a side project that required a web scraping of the Twitter platform. The main objective of the project was to extract the Twitter handlers for a list of particular accounts. Everything seems reasonable if there were 10–20 accounts but I was presented with a list of more than 12K records. The first thing that came to my mind was to use of course the Twitter API but I couldn’t find a way to retrieve the username based on the information I was given. Even if it was possible it would still take quite some…
In layman terms a generators are functions that produce sequence of results similar to regular functions. The difference between both lays in the method of returning actual results.
In regular functions, you would use something as
return result to return a result to the caller, while generators use the
yield keyword, which stop the generator from further execution and yields (returns if you like to) the current value. A simple example illustrates the behavior much better than words.
# regular-function.pyimport randomdef list_func(n):
m = 0
arr = 
while m < n:
m += 1
Network, system and software engineer with true passion about technology. Love to read and spend time in nature.