Making async http requests with python-aiohttp

In this post I’d like to test limits of python aiohttp and check its performance in terms of requests per minute. Everyone knows that asynchronous code performs better when applied to network operations, but it’s still interesting to check this assumption and understand how exactly it is better and why it’s is better. I’m going … Continue reading Making async http requests with python-aiohttp

How to rename all files in a folder using Python

let's assume the folder is user_data, relative to the current working directory (where the Python script is in). The code below was tested on Windows. import os for filename in os.listdir("./user_data"):     # print(filename)     cwd = os.path.dirname(os.path.abspath(__file__)) + '\\user_data\\'     if filename.split('.')[1] == 'jpg':         new_filename = filename.split('.')[0] + '_search' + '.jpg'         print(new_filename) … Continue reading How to rename all files in a folder using Python

Python packages and the purpose of __init__.py file

Packages are a way of structuring Python’s module namespace by using “dotted module names”. For example, the module name A.B designates a submodule named B in a package named A. Just like the use of modules saves the authors of different modules from having to worry about each other’s global variable names, the use of … Continue reading Python packages and the purpose of __init__.py file

How to run system commands Java (Linux environment)

In Python, we use import os os.system('sudo vncserver stop')   What about in Java. Below is one example. import java.io.*;   public class java_system_call {       public static void main(String args[]) {           String s = null;           try {                       // run the Unix "ps -ef" command             // using the Runtime exec method:             Process … Continue reading How to run system commands Java (Linux environment)