Python While Loop

The while loop in Python is basically just a way to construct code that will keep repeating while a certain expression is true. To create a while loop, you’ll need a target statement and a condition, and the target statement is the code that will keep executing for as long as the condition remains true. The syntax […]

Read More

Python’s Count Method

In Python, the count method returns the count of how many times an object occurs in a list. The syntax for the count method is really straightforward: list.count(obj) The above example represents the basic syntax for this method. When you’re using it in context, you’ll need to replace the ‘list’ keyword with the actual name […]

Read More

Resetting the Recursion Limit

What Is The Recursion Limit? A recursive function is one that calls itself, looping through data to generate a result. However, in Python, there is a limit to the number of times a function can call itself. The limit is set to the maximum depth of Python’s interpreter stack.  Python’s default recursion limit is 1000, […]

Read More

Swapping Values in Python

Swapping the values of two variables in Python is actually a really simple task. Python makes it fairly easy to swap two values without a lot of bulky code or weird hacks. Check out how easy it is to swap two numbers with each other using the built in methods below: x, y = 33, […]

Read More

How to Check for Anagrams In Python

In Python, there’s a fairly straightforward way to create a method that can be used to check strings against each other to see if the two strings are anagrams. Check out the function below to see the method in action — essentially it works by using the “==” comparison operator to see if the strings on […]

Read More

Using Break and Continue Statements in Python

In Python, break statements are used to exit (or “break) a conditional loop that uses “for” or “while”. After the loop ends, the code will pick up from the line immediately following the break statement. Here’s an example: even_nums = (2, 4, 6) num_sum = 0 count = 0 for x in even_nums: num_sum = […]

Read More

Quick Tip: Using Sets in Python

In Python, sets are lists that don’t contain any duplicate entries. Using the set type is a quick and easy way to make sure that a list doesn’t contain any duplicates. Here’s an example of how you would use it to check a list for duplicates: a = set([“Pizza”, “Ice Cream”, “Donuts”, “Pizza”]) print a […]

Read More

Python’s SQLAlchemy vs Other ORMs

Overview of Python ORMs As a wonderful language, Python has lots of ORM libraries besides SQLAlchemy. In this article, we are going to take a look at several popular alternative ORM libraries to better understand the big picture of the Python ORM landscape. By writing a script that reads and writes to a simple database […]

Read More

Python’s Django vs Ruby on Rails

Python vs Ruby Ruby is a dynamic, reflective, object-oriented general-purpose programming language which was designed and developed in the mid-1990s. Compared to Python, which treats code readability above everything else, the philosophy behind Ruby is that programmers should have the flexibility, freedom and power to write concise and compact code. The most important difference between […]

Read More

How to Install Django on Windows, Mac and Linux

In this article, we are going to learn how to install Django on Windows, Mac and Linux. Since Mac and Linux are both derived from the Unix platform, the instructions about installing Django on Mac and Linux are almost identical to each other and we will present them in the same section. Windows, however, is […]

Read More