Python In Plain English
Go deeper with the language powering everything.

2.5K Followers
·

Image for post
Image for post
Photo by Anne Preble on Unsplash

In this third part of our article series we will learn how to code the secure session checkout creator for Stripe.

What we will learn today:

  • Register new products and prices in Stripe
  • Code the checkout session creator with Stripe

Register new products in Stripe

In our previous article we made possible for the user to check the available products in our website and choose one between the options: Regular, Pro and Platinum. Now before continuing defining the payment workflow we need to register this products with associated prices in Stripe

Go to Stripe Dashboard → Products → + Add product and fill the basic information for a product. For the pricing choose one time and fill the price we defined in our front store…


Image for post
Image for post
Photo by Markus Spiske on Unsplash

Introduction

In this part, we’ll perform exploratory data analysis (EDA) on our data, which is a crucial part of most machine learning problems. Although we might not end up increasing our score, we will draw invaluable insights from our data, which is often one of the primary objectives of real-world machine learning. We are going to use some of the traditional EDA techniques, but we’ll also touch on a few underused ones as well. You can find the notebook for this tutorial here.

Without further ado, let’s get coding (in Colab)!

Ceteris Paribus

From the previous article, we have a vague idea of what partial dependence is, the problem it tries to solve, and how it does so. However, quite a few of the details were left out, so this article will be devoted to filling those empty spots. …


Image for post
Image for post

NLTK is an essential library supports tasks such as classification, stemming, tagging, parsing, semantic reasoning, and tokenization in Python. It’s basically your main tool for natural language processing and machine learning. Today it serves as an educational foundation for Python developers who are dipping their toes in this field (and machine learning).

It’s a free and open-source library that is available on Windows, Mac OS and Linux with plenty of tutorials to make your entry into the world of NLP smooth.

Resources

· Documentation https://www.nltk.org/

· NLTK Bookhttp://www.nltk.org/book/

Features

  • Tokenization Sentences/Words
  • Part-of-speech tagging
  • Stemming, Lemmatization
  • Sentiment…

It has been a while that I posted data structure since I covered stack. In this post, I would like to talk about one of the easiest trees, Heap. Let’s crack into it!

Priority Queue

Before understanding Heap, you need to know what Priority Queue is. Priority Queue is an abstract data type(ADT) in which data has priority and the one that has higher priority will be deleted first. It has three primary operations. Hold on, what is an abstract data type? It is data structure like queue and stack.

  • insert(Q, x) — insert an item with a key x into priority queue…

Getting started with BDD, Cucumber, and Gherkin

Image for post
Image for post
Photo by Scott Graham on Unsplash

Back Story

Testing applications is something that I find extremely important. Sadly, the urge to actually sit down and write out unit tests, write behavior tests, or utilize test-driven development is something that I continually put off. In fact, writing the tests gets put off for so long, that in the end, they never end up getting written. Obviously, this is a pretty bad habit. Fortunately, all of that is about to change! Utilizing a previous API I wrote (you can read more about that here), we are going to create a couple of behavior tests for it.

BDD, Cucumber, and Gherkin

Before we start writing any code, I want to take a moment to explain a few things. Essentially, when tied in with Agile, Behavior Driven Development is very popular in the business world. It helps your non-technical users hash out the features they want to see in their new systems. At the same time, it helps developers understand the requests of the business. In a nutshell, one of the major goals of BDD is to encourage collaboration between teams. …


Image for post
Image for post
Photo by Julie Fader on Unsplash

In these article series we will learn how to setup a simple payment workflow with Django using the Stripe payment platform. We will use the Stripe dashboard to manage products and configure our pricing model and taxes so we don’t need to worry about handling this in our app.

We will keep track as well of unique users registering new customers in Stripe every time we have a new registration in our app, this will be useful for tracking customer value and providing customer support. I expect from the reader some minimal knowledge of Python and Django but I will explain every step in detail from the beginning. …


Image for post
Image for post
Photo by Girl with red hat on Unsplash

Boosting your scripting productivity using slick custom keyboard shortcuts

From Simple Shortcuts to Quick Python Snippets

Writing fast code is a trademark of our perception of what constitutes an efficient programmer. Even though the bottleneck for good programming performance is most definitely not how fast you type, it can have a very positive effect in the way you think and solve problems.

Today I want to share an approach to optimizing your coding productivity by using keyboard shortcuts with AutoHotkey to write a variety of repetitive python snippets of code.

Why AutoHotkey?

AutoHotkey is a free, open-source custom scripting language for Microsoft Windows, initially aimed at providing easy keyboard shortcuts (or hotkeys), to allows users of every level of computer skill to automate repetitive tasks in any Windows application. …


GIFS Dominate The Internet

Image for post
Image for post
Gif made using Python from Google Trends Data

Introduction

Today we will look at how to make gifs. Amaze your readers and viewers with these stunning GIFS. Make your point with style!

I will leave the complete code at the bottom of the article.

1. Get The Data

First, we need some data to visualize. You could get yours using this link. Or by going to trends and configuring it yourself. Once we are there, we need to download the data to get started.

Image for post
Image for post
Screenshot from Google Trends, click on the red download link to get the data.

Once we downloaded our data, it will look something like this.

Image for post
Image for post
Our Data, Delete the lines highlighted here in the clue.

We have to do one more cosmetics thing, delete the lines highlighted in blue in the above picture. Our basic aim is to convert this into a simple CSV. We could solve this later programmatically, but this allows us to make our code more understandable later. …


Image for post
Image for post

Many simple “for loops” in Python can be replaced with list comprehensions. You can often hear that list comprehension is “more Pythonic” (almost as if there was a scale for comparing how Pythonic something is, compared to something else 😉). In this article, I will compare their performance and discuss when a list comprehension is a good idea, and when it’s not.

Filter a list with a “for loop”

Let’s use a simple scenario for a loop operation — we have a list of numbers, and we want to remove the odd ones. …


Image for post
Image for post
Photo by Gautier Salles on Unsplash

In this article series I want to help total beginners in Django to setup real-world apps with minimal knowledge of the platform to be dangerous and build awesome modern web apps.

In this first article we will cover the basic of setting the up the development environment and installing Django with the default admin panel. No previous knowledge of Python is required for this article.

What you will learn today:

  • Create and work with a Python virtual environment.
  • Install project dependencies
  • Setup a Django project and database
  • Setup the Admin user and panel

Installing dependencies

Open your favorite terminal, create a project folder and we will start installing our dependencies with Python pip. We will use a virtual environment to setup our development environment dependencies to be isolated from our system. So first let’s install the virtualenv package, create the development virtual environment and activate it. …

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store