D
Dylan Parry
Hi,
I am by no means a Python programmer, but I am dabbling with it and trying
to create a simple program that reports how many emails I have to
download. So far, using the poplib extension, I have got:
def checkEmail():
email = poplib.POP3('mail.mydomain.ext')
email.user('user')
email.pass_('password')
number = email.stat()
email.quit()
if (number[0] == 0):
return "No new emails"
elif (number[0] == 1):
return "1 new email"
else:
string = str(number[0])
string += " new emails"
return string
Which is fine as long as the server doesn't timeout, or my machine isn't
doing something else that takes up all my bandwidth! Coming from a Java
background, I was wondering if there is anything similar in Python that
allows me to do something like:
try {
something();
}
catch (exception e) {
somethingelse();
}
Where if the "something()" fails then the "somethingelse()" will be ran
instead? Or is there another way that I can deal with timeouts in Python?
Cheers,
I am by no means a Python programmer, but I am dabbling with it and trying
to create a simple program that reports how many emails I have to
download. So far, using the poplib extension, I have got:
def checkEmail():
email = poplib.POP3('mail.mydomain.ext')
email.user('user')
email.pass_('password')
number = email.stat()
email.quit()
if (number[0] == 0):
return "No new emails"
elif (number[0] == 1):
return "1 new email"
else:
string = str(number[0])
string += " new emails"
return string
Which is fine as long as the server doesn't timeout, or my machine isn't
doing something else that takes up all my bandwidth! Coming from a Java
background, I was wondering if there is anything similar in Python that
allows me to do something like:
try {
something();
}
catch (exception e) {
somethingelse();
}
Where if the "something()" fails then the "somethingelse()" will be ran
instead? Or is there another way that I can deal with timeouts in Python?
Cheers,