Archives de catégorie : Non classé

Debug python applications

Print all attributes of an object by reflection from pprint import pprint pprint(vars(my_object))

Publié dans Non classé | Laisser un commentaire

Slicing in python

Slicing in python Goal A slicing selects a range of items in a sequence object (e.g., a string, tuple or list). General syntax a[start:stop] : from start through stop-1 a[start:] : from start through the end of the array a[:stop] … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Windows dos script tips

Dos tips List process and pid netstat -a -o -b | grep -i ‘4200’ Script tips To get the command used to call the batch file (could be foo, ..\foo, c:\bats\foo.bat, etc.) %0 To get the nth argument passed to … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Concurrent futures with python 3.8

Purpose and overview The concurrent.futures module provides a high-level interface for asynchronously executing callables. The asynchronous execution can be performed with 2 flavors: – threads, using ThreadPoolExecutor – separate processes, using ProcessPoolExecutor. Both implement the same interface, which is defined … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

threads in python

Purpose and overview This module constructs higher-level threading interfaces on top of the lower level _thread module. We have other alternatives to the threading module, but the module is still an appropriate model if you want to run multiple I/O-bound … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Interoperate with win32 api with python

win32 api with python pywin32 is currently the best way to manipulate windows API. It is maintained and the github source code is also public and available here : pywin32 github The imports used in this page are: import win32com.client … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Implementation of common operators in python

Publié dans Non classé | Laisser un commentaire

The with statement

The semantic of the with statement The following code: with EXPRESSION as TARGET: SUITE is semantically equivalent to: manager = (EXPRESSION) enter = type(manager).__enter__ exit = type(manager).__exit__ value = enter(manager) hit_except = False   try: TARGET = value SUITE except: … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

lambda,dynamic function calls and comprehensions in python

Comprehension A concise way to create a new list or a new dictionary from an existing iterable or sequence. Syntax : It consists of brackets (for list comprehension) and of braces(for dict comprehension) containing an expression followed by a for … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

python: common string functions

chapters transformation functions finding functions checking functions transformation functions transformations functions doesn’t modify the current string since strings are imitable.Instead of,they return a copy. remove leading and trailing whitespace:strip() remove leading whitespace:lstrip() remove trailing whitespace:rstrip() split a string into a … Continuer la lecture

Publié dans Non classé | Laisser un commentaire