>>Probably you need to import NoSuchDomain from rwhois:
>>from rwhois import WhoisRecord, NoSuchDomain
>>
>>then use
>>   except NoSuchDomain:

I tried adding:
        from rwhois import WhoisRecord, NoSuchDomain
        who = WhoisRecord()
        self.totalchecked = 0
        self.availdomains = []
        for potdomain in self.potdomains:
            try: 
                who.whois(potdomain)
                self.availdomains.append(potdomain)
            except NoSuchDomain:
                pass
            self.totalchecked+=1

But I get back:

Traceback (most recent call last):
  File "domainspotter.py", line 150, in <module>
    runMainParser()
  File "domainspotter.py", line 147, in runMainParser
    td.run()
  File "domainspotter.py", line 71, in run
    checkdomains.lookup()
  File "domainspotter.py", line 108, in lookup
    from rwhois import WhoisRecord, NoSuchDomain
ImportError: cannot import name NoSuchDomain

Maybe I need to import something else to be able to throw it. 

I think if someone can explain a more general form of this I would be on better 
footing: To use a custom error code (from a module) in a loop or anywhere else, 
do I need to import the code itself? I had assumed that once I imported the 
module that defined the error code, I could catch it just like a core Python 
error code.

>>In general, when you ask a question here, "I tried X and it did not 
>>work" is not very informative and makes it difficult to give a good 
>>answer. It is very helpful to show the actual code you tried and the 
>>actual error message, including the full traceback. The error message 
>>and traceback include a lot of very helpful information; including them 
>>will greatly improve your chance of a correct answer.

Commented on this with the warning text in last response. Will endeavour to do 
better:-)

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to