From 0ecbbae7924bc7af36e0b131c3f1826f49b534a2 Mon Sep 17 00:00:00 2001 From: Mauro Scomparin Date: Wed, 12 Apr 2017 02:34:08 +0200 Subject: [PATCH] Aggiunto funzione per nome file e pretty print. --- money.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/money.py b/money.py index 1b08232..6a6b063 100755 --- a/money.py +++ b/money.py @@ -2,6 +2,7 @@ from time import localtime, strftime from os.path import expanduser, join +from pprint import pprint def leggi_tipo(): t = input('tipo (+/-) [-]: ') @@ -58,12 +59,18 @@ def scrivi_movimento(path, m): f.write('\n') return +def file_output(): + home = expanduser('~') + out_file_name = 'movimenti.dat' + out_file = join(home, 'dati', out_file_name) + return out_file + print("money 0.0.1") -home = expanduser('~') -out_file_name = 'movimenti.dat' -out_file = join(home, 'dati', out_file_name) +out_file = file_output() print('file output:', out_file) m = leggi_movimento() scrivi_movimento(out_file, m) -print('scritto:', m) +print('scritto:') +pprint(m) print('grazie.') + -- 2.25.1