Thank you (Cameron and Alan) for your review and feedback. This solved the
issue perfectly!
Thank you.
On Friday, October 2, 2015 11:49 PM, Cameron Simpson
wrote:
On 03Oct2015 00:51, ALAN GAULD wrote:
>On 02/10/15 23:57, Nym City
Hello,
I am trying to get IP addresses for about 500 public domains but I think for
some where resolution is not available - my exception handling breaks the code.
To troubleshoot, I added several Print statements to see what I was getting and
it looks like my blank list is getting populated
On 02/10/15 23:57, Nym City via Tutor wrote:
socket.gaierror: [Errno 11004] getaddrinfo failed
...
for name in ListOfHostNames:
try:
ResolveHostname = socket.gethostbyname(name)
print(ResolveHostname)
newFile.write(ResolveHostname + "\n")
On 03Oct2015 00:51, ALAN GAULD wrote:
On 02/10/15 23:57, Nym City via Tutor wrote:
socket.gaierror: [Errno 11004] getaddrinfo failed
...
for name in ListOfHostNames:
try:
ResolveHostname = socket.gethostbyname(name)
print(ResolveHostname)
On Sat, 11 Sep 2010 04:47:13 am Michael Powe wrote:
No problem, I am working on getting this sorted out. The
documentation seems to be written as reminder for people who already
know how this stuff works, rather than as a clear explanation for
anybody working with it.
That's because the job
Hello,
I can't work out how to suppress stacktrace printing when exceptions
are thrown.
I want the thrown exception to pass a message on the console, just
like Java does when I catch an exception and print e.getMessage().
I tried some of the examples of controlling traceback through the
I can't work out how to suppress stacktrace printing when exceptions
are thrown.
I want the thrown exception to pass a message on the console, just
like Java does when I catch an exception and print e.getMessage().
I tried some of the examples of controlling traceback through the
Michael Powe wrote:
I can't work out how to suppress stacktrace printing when exceptions
are thrown.
[snip rant]
It might have been a good idea to read a tutorial like
http://docs.python.org/tutorial/errors.html#handling-exceptions
or ask before you got annoyed enough to write that rant ;)
Michael Powe wrote:
On Fri, Sep 10, 2010 at 03:56:51PM +0200, Peter Otten wrote:
Michael Powe wrote:
I can't work out how to suppress stacktrace printing when exceptions
are thrown.
[snip rant]
It might have been a good idea to read a tutorial like
On Fri, Sep 10, 2010 at 04:42:35PM +0200, Peter Otten wrote:
Michael Powe wrote:
On Fri, Sep 10, 2010 at 03:56:51PM +0200, Peter Otten wrote:
Michael Powe wrote:
I can't work out how to suppress stacktrace printing when exceptions
are thrown.
WRONG:
try:
... 1/0
...
On Mon, 29 Dec 2008 16:57:44 +0100, spir wrote:
On Mon, 29 Dec 2008 09:10:45 -
Alan Gauld alan.ga...@btinternet.com wrote:
bob gailer bgai...@gmail.com wrote
Also IMHO it is bad design to put a lot of code inside a try block.
In this case the user might make a mistake on day and
On Mon, 29 Dec 2008 16:57:44 +0100, spir wrote:
On Mon, 29 Dec 2008 09:10:45 -
Alan Gauld alan.ga...@btinternet.com wrote:
bob gailer bgai...@gmail.com wrote
Also IMHO it is bad design to put a lot of code inside a try block.
In this case the user might make a mistake on day
On Wed, Dec 31, 2008 at 8:33 AM, David da...@abbottdavid.com wrote:
On Mon, 29 Dec 2008 16:57:44 +0100, spir wrote:
On Mon, 29 Dec 2008 09:10:45 -
Alan Gauld alan.ga...@btinternet.com wrote:
bob gailer bgai...@gmail.com wrote
Also IMHO it is bad design to put a lot of code
On Tue, Dec 30, 2008 at 4:33 PM, David da...@abbottdavid.com wrote:
Thank you all for the tips. Next to do is to get the dates in one raw_input
with the correct format and to check for a valid year, month, and day. Here
is what I have now;
ynum = int(time.strftime(%Y, time.gmtime())) -
Jervis Whitley wrote:
On Wed, Dec 31, 2008 at 8:33 AM, David da...@abbottdavid.com
mailto:da...@abbottdavid.com wrote:
On Mon, 29 Dec 2008 16:57:44 +0100, spir wrote:
On Mon, 29 Dec 2008 09:10:45 -
Alan Gauld alan.ga...@btinternet.com
On Wed, Dec 31, 2008 at 11:18 AM, David da...@abbottdavid.com wrote:
. I still need to get it to prduce an error if the year is 0 or 2009, the
month is 0 or 13 and the day is 0 or 32.
Try using the datetime module to check validity of entered data.
example:
import datetime
David da...@abbottdavid.com wrote
Is this the correct way to handle a ValueError exception and should
I get in the practice of catching them?
Yes and Yes.
Although I woulfd move the except clause up to just after the input
section
(which is where the errors will be raised). A couple of
bob gailer bgai...@gmail.com wrote
Also IMHO it is bad design to put a lot of code inside a try block.
In this case the user might make a mistake on day and then is forced
to reenter the year and month!
Obviously there is no absolute rule here but I disagree.
One of the biggest advantages
On Mon, 29 Dec 2008 09:10:45 -
Alan Gauld alan.ga...@btinternet.com wrote:
bob gailer bgai...@gmail.com wrote
Also IMHO it is bad design to put a lot of code inside a try block.
In this case the user might make a mistake on day and then is forced
to reenter the year and month!
spir denis.s...@free.fr wrote
I often use the else clause of try...except. This allows putting
only the
minimum problematic code lines inside the try block, which is good
both for
legibility andto avoid catching unexpected errors. The else will be
executed
only in case of no exception:
try:
Hi,
Is this the correct way to handle a ValueError exception and should I
get in the practice of catching them? Also any suggestions on the program.
thanks
-david
--
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu
___
Tutor
David wrote:
Hi,
Is this the correct way to handle a ValueError exception and should I
get in the practice of catching them? Also any suggestions on the program.
thanks
-david
Might help if I included the program :)
#!/usr/bin/python
import time
print Enter year as
print Enter month
David wrote:
David wrote:
Hi,
Is this the correct way to handle a ValueError exception and should I
get in the practice of catching them?
Well yes and no.
I think it is better to use the string method isdigit to test for digits
only.
Also IMHO it is bad design to put a lot of code
Krishna wrote:
When I have this piece of code in a function, it works fine. So is
this some limitation of directly working out off the console?
It is indeed valid Python (you don't have to have empty lines after
try-except in a real Python program).
Seems the console supports complete code
On Sun, 2005-09-25 at 19:44 +0530, Krishna wrote:
snip
Think the mail system screwed up the formatting! But am fairly sure
that I have indented it correctly in the console. Try and Except are
in the column. Any other hints?
Make sure you're not mixing tabs and spaces. A lot of editors uses
25 matches
Mail list logo