Python tutorials

Pyramid Explained

What is Pyramid Pyramid is a Python web framework created from the combination of Pylons and repoze.bfg, resulting in a flexible, easy to use framework. Pyramid puts much of its focus in being flexible, so no application will be constrained by decisions made by the Pyramid creators. For example, you can use Mako or Chameleon for templating, just about any type of database for persistence, and a number of different methods for view routing (the list goes on). Many features […]

Read more

How to Exploit the Heartbleed Bug

First we explained how it worked, and now, thanks to Jared Stafford (and stbnps on Github for explanations) we can show you how to exploit it. Heartbleed is a simple bug, and therefore a simple bug to exploit. As you’ll see below, it only takes about a single page of Python to exploit this bug. Before we get to the code, here are a few reference links to help you understand the SSL protocol: The Code #!/usr/bin/python # Quick and […]

Read more

Example: Upload a File to AWS S3 with Boto

Example Code Amazon Web Services (AWS) is a collection of extremely popular set of services for websites and apps, so knowing how to interact with the various services is important. Here, we focus on the Simple Storage Service (S3), which is essentially a file store service. All files must be assigned to a bucket, which is assigned a name and can be addressed by http://s3.amazonaws.com/{bucket}/{key}. Each file is assigned a unique key, which can be used later on to retrieve […]

Read more

How to Send an Email with boto and SES

Introduction Pretty much every user-based app and website needs to send an email to the user at some point, so eventually you’ll have to deal with the joyous world of programmatic emailing. There are quite a few services popping up to help you with this, but with every app having its own unique requirements, few of these services adequately get the job done. So having faced the problem a few times (and in a few languages), I decided to write […]

Read more

The Best Machine Learning Libraries in Python

Introduction There is no doubt that neural networks, and machine learning in general, has been one of the hottest topics in tech the past few years or so. It’s easy to see why with all of the really interesting use-cases they solve, like voice recognition, image recognition, or even music composition. So, for this article I decided to compile a list of some of the best Python machine learning libraries and posted them below. In my opinion, Python is one […]

Read more

Why Beginners Should Learn Python

From some of my other posts you’ve probably noticed that I’m a big fan of Node.js. While this is true, and has been my go-to language for a while now, I don’t always recommend it to everyone. Just starting out in programming and computer science can be a bit daunting. Which language should you pick? Which IDE should you use? And more importantly, why? In my opinion, the most important thing you should do when programming is choose the right […]

Read more

Python async/await Tutorial

Asynchronous programming has been gaining a lot of traction in the past few years, and for good reason. Although it can be more difficult than the traditional linear style, it is also much more efficient. For example, instead of waiting for an HTTP request to finish before continuing execution, with Python async coroutines you can submit the request and do other work that’s waiting in a queue while waiting for the HTTP request to finish. It might take a bit […]

Read more

Install Python on Mac OSX

As with just about any open source software package, there are quite a few ways to install Python on Mac OSX. I figured it would be helpful to detail a few of the easiest ways to install Python, including the following: These are the most commons you’ll encounter, and each method has its own purpose, all of which I’ll detail in the sections below. Instructions for installing Python 2 and 3 are different in most cases (but not by much), […]

Read more

Python: Check if a File or Directory Exists

There are quite a few ways to solve a problem in programming, and this holds true especially in Python. Many times you’ll find that multiple built-in or standard modules serve essentially the same purpose, but with slightly varying functionality. Checking if a file or directory exists using Python is definitely one of those cases. Here are a few ways to check for existing files/directories and their nuances. Throughout these examples we’ll assume our current working directory has these files and […]

Read more

The Python Property Decorator

It is often considered best practice to create getters and setters for a class’s public properties. Many languages allow you to implement this in different ways, either by using a function (like person.getName()), or by using a language-specific get or set construct. In Python, it is done using @property. In this article I’ll be describing they Python property decorator, which you may have seen being used with the @decorator syntax: class Person(object): def __init__(self, first_name, last_name): self.first_name = first_name self.last_name […]

Read more
1 168 169 170 171 172 181