Merge branch 'master' of https://git.briq.it/Emanuele/MarkoprintWiFi.git
commit
a6fb32e3a8
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Created on Fri Sep 27 11:21:37 2019
|
||||||
|
|
||||||
|
@author: Guido Longoni - guidolongoni@gmail.com
|
||||||
|
"""
|
||||||
|
|
||||||
|
regole = [
|
||||||
|
(lambda x: isinstance(x, int) and x > 0, 'è un intero positivo'),
|
||||||
|
(lambda x: isinstance(x, int) and x < 0, 'è un intero negativo'),
|
||||||
|
(lambda x: isinstance(x, float) and x > 0, 'è un reale positivo'),
|
||||||
|
(lambda x: isinstance(x, float) and x < 0, 'è un reale negativo'),
|
||||||
|
(lambda x: True, 'non è un numero'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
test = [1,-1,'ciao',3.14,-0.5]
|
||||||
|
|
||||||
|
risultato_filtro = [str(dato)+' '+next(regola[1] for regola in regole if regola[0](dato)) for dato in test]
|
||||||
Loading…
Reference in New Issue