try:
z = input() #premendo solo invio
except EOFError:
print "eof error"
#output: Message: unexpected EOF while parsing
considerando il messaggio di errore: unexpected EOF
non dovrebbe essere specifico per intercettare tale errore?
try:
z = input() #premendo solo invio
except EOFError:
print "eof error"
#output: Message: unexpected EOF while parsing
considerando il messaggio di errore: unexpected EOF
non dovrebbe essere specifico per intercettare tale errore?
try:
z = input() #premendo solo invio
except Exception as xc:
print type( xc )
#output: <type 'exceptions.SyntaxError'>
try:
z = input() #premendo solo invio
except SyntaxError:
print "syntax error"
#output: syntax error
https://docs.python.org/2.7/library/functions.html#input
ciao Emilio,
ma “EOFError” in quale caso viene intercettato?
per caso nella lettura di un file?
Ciao Salvio
Ho poco feeling con le eccezioni … non saprei, spiacente.
Vedo pero’ che input() in Python 3 puo’ generare appunto EOFError
ok allora appena posso provo con Py 3x grazie