Cheatsheet

Tips in alphabetical order

  • input GUI
  • partial
  • reduce

This page will contain alphabetical tips for python. You get the code here:

Open the cmd and, if you have installed git, write this:

git clone https://github.com/formazione/python_cheatsheet

Input GUI

GUI Input in a window with Python

 

Partial

With partial you gave a fixed value to an existing function so that you do not have to rewrite the original

Example

out:

 

Reduce

Reduce, from the module functools, lets you take a function with 2 arguments and use it with an iterable (ex: a list) to do with all the items of the iterable (list) what the function does with the 2 arguments. For example it can sum all the items in the list if the function sums the 2 arguments or can concatenate every string, if the original function concatenates two string.

Example

out: