Topics Search

Python

Home » Python (179)
  • Page 1 of 9
  • »
 

How to embed Python code in C program

How to embed Python code in C program Icon
Python is one of the most popular programming languages due to its simple syntax, ease of learning and cross-platform support. Besides, many high quality Python libraries and modules are available at your disposal, allowing you to do heavy lifting with only a few lines of code. This makes Python one of the most productive ways to develop prototypes. However, Python is not as fast as C programming language, and many performance-critical production software such as the Linux operating system, web servers and databases are written in C. If you are developing a program in C, but some part of it needs to be written in Python, you can actually write a Python module for that and embed the Python module in a C program using Python/C API.
 
Advertisement:
 

Introducing Pandas

Introducing Pandas Icon
In this tutorial I will give a basic introduction to pandas. Oh, I don't mean the animal panda, but a Python library! Thus, pandas is a data analysis library that has the data structures we need to cleanse raw data into a form which is suitable for analysis (i.e. tables). It is important to note here that since pandas performs important tasks such as aligning data for comparison and merging of data sets, handling of missing data, etc., it has become a de facto library for high-level data processing in Python (i.e. statistics).
 

How To Write Conditional Statements in Python 3

How To Write Conditional Statements in Python 3 Icon
When we fully execute each statement of a program, moving from the top to the bottom with each line executed in order, we are not asking the program to evaluate specific conditions. By using conditional statements, programs can determine whether certain conditions are being met and then be told what to do next. Let’s look at some examples where we would use conditional statements:
 

How to send emails using Python

How to send emails using Python Icon
As a learning exercise, I recently to dug into Python 3 to see how I could fire off a bunch of emails. There may be more straightforward methods of doing this in a production environment, but the following worked well for me. So, here’s a scenario: You have the names and email addresses of a bunch of contacts. And you want to send a message to each one of those contacts, while adding a “Dear [name]” at the top of the message.
 

Building RESTful APIs With Flask: ORM Independent

Building RESTful APIs With Flask: ORM Independent Icon
In the first part of this three-part tutorial series, we saw how to write RESTful APIs all by ourselves using Flask as the web framework. In the second part, we created a RESTful API using Flask-Restless which depends on SQLAlchemy as the ORM. In this part, we will use another Flask extension, Flask-Restful, which abstracts your ORM and does not make any assumptions about it.
 

How To Use String Formatters in Python 3

How To Use String Formatters in Python 3 Icon
Python’s str.format() method of the string class allows you to do variable substitutions and value formatting. This lets you concatenate elements together within a string through positional formatting. This tutorial will guide you through some of the common uses of formatters in Python, which can help make your code and program more readable and user friendly.
 

How To Use Variables in Python 3

How To Use Variables in Python 3 Icon
Variables are an important programming concept to master. They are essentially symbols that stand in for a value you’re using in a program. This tutorial will cover some variable basics and how to best use them within the Python 3 programs you create.
 

Building RESTful APIs With Flask: An ORM With SQLAlchemy

Building RESTful APIs With Flask: An ORM With SQLAlchemy Icon
In this part, we will use a Flask extension, Flask-Restless, which simply generates RESTful APIs for database models defined with SQLAlchemy. I will take the same sample application as in the last part of this series to maintain context and continuity.
 

How to Convert OpenCV Image Data from Python to C

How to Convert OpenCV Image Data from Python to C Icon
OpenCV officially provides both C++ and Python APIs for developers. Most of the time, developers just need to use one kind of programming languages to read, write and process images with hundreds of computer vision algorithms. However, if you want to use OpenCV Python APIs with an extended C/C++ library, it will be tricky to pass the data. In this article, I will share how to read camera stream with OpenCV-Python and detect barcode with Dynamsoft C/C++ Barcode SDK.
 

How To Handle Plain Text Files in Python 3

How To Handle Plain Text Files in Python 3 Icon
This tutorial will briefly describe some of the format types Python is able to handle. After a brief introduction to file formats, we'll go through how to open, read, and write a text file in Python 3. When you're finished with this tutorial, you'll be able to handle any text file in Python.
 

Building RESTful APIs With Flask: The DIY Approach

Building RESTful APIs With Flask: The DIY Approach Icon
In this three-part tutorial series, I will cover different ways in which RESTful APIs can be created using Flask as a web framework. In the first part, I will cover how to create class-based REST APIs which are more like DIY (Do it yourself), i.e. implementing them all by yourself without using any third-party extensions. In the latter parts of this series, I will cover how to leverage various Flask extensions to build more effective REST APIs in an easier way.
 

How to Use Python to Find the Zipf Distribution of a Text File

How to Use Python to Find the Zipf Distribution of a Text File Icon
Thus, Zipf's law is trying to tell us that a small number of items usually account for the bulk of activities we observe. For instance, a small number of diseases (cancer, cardiovascular diseases) account for the bulk of deaths. This also applies to words that account for the bulk of all word occurrences in literature, and many other examples in our lives.
 

Multi-Line Lambdas in Python

Multi-Line Lambdas in Python Icon
I need to preface all of this with a disclaimer: I love Python, but I am able to see plenty of faults with it. In this article, I attempt to provide a very roundabout way of working around one of those faults: the lack of multi-line lambdas. This is not to say that this is a good solution, but it may be one of the best that we have for certain cases. Try and see if one of the typical workarounds is the best option before settling on this.
 

How to Crawl A Web Page with Scrapy and Python 3

How to Crawl A Web Page with Scrapy and Python 3 Icon
In this tutorial, you’ll learn about the fundamentals of the scraping and spidering process as you explore a playful data set. We'll use BrickSet, a community-run site that contains information about LEGO sets. By the end of this tutorial, you’ll have a fully functional Python web scraper that walks through a series of pages on Brickset and extracts data about LEGO sets from each page, displaying the data to your screen.
 

Httpstat: Simple cURL Stats

Httpstat: Simple cURL Stats Icon
There are a lot of tools out there that do great, advanced things but present them as well as they could be presented. I wont knock cURL for anything -- it's an amazing tool many of us can't live without; what I will say, however, is that it's nice having tools on top of cURL for better presentation or extended functionality.
 

An Introduction to String Methods in Python 3

An Introduction to String Methods in Python 3 Icon
Python has several built-in methods associated with the string data type. These methods let us easily modify and manipulate strings. We can think of methods as being actions that we perform on elements of our code. Built-in methods are those that are defined in the Python programming language and are readily available for us to use.
 

How to publish your own Python Package on PyPi

How to publish your own Python Package on PyPi Icon
Want to share your Python code with other developers? Want to make your users’ lives easier when installing your package? Then you should publish your Python packages to PyPi. The good news is that it is now easier than ever. This is a short guide that will walk you through the process and point you toward relevant documentation along the way.
 

How To Format Text in Python 3

How To Format Text in Python 3 Icon
As strings are often made up of written text, there are many instances when we may want to have greater control over how strings look to make them more readable for humans through punctuation, line breaks, and indentation. In this tutorial, we’ll go over some of the ways we can work with Python strings to make sure that all output text is formatted correctly.
 

An Introduction to Working with Strings in Python 3

An Introduction to Working with Strings in Python 3 Icon
A string is a sequence of one or more characters (letters, numbers, symbols) that can be either a constant or a variable. Made up of Unicode, strings are immutable sequences, meaning they are unchanging. This Python tutorial will go over how to create and print strings, how to concatenate and replicate strings, and how to store strings in variables.
 

How To Write Your First Python 3 Program

How To Write Your First Python 3 Program Icon
The “Hello, World!” program is a classic and time-honored tradition in computer programming. Serving as a simple and complete first program for beginners, as well as a good program to test systems and programming environments, “Hello, World!” illustrates the basic syntax of programming languages. This tutorial will walk you through writing a “Hello, World” program in Python 3.
Home » Python (179)
  • Page 1 of 9
  • »