Python effective TLD library bug fix

    Some cool people commented on bugs in the etld library in the previous post about it. I've taken the opportunity to fix the bug, and a new release is now available at If you've got specific examples of domains which either didn't work previously, or don't work now, let me know. I want to add unit tests to this code ASAP.

posted at: 13:57 | path: /python/etld | permanent link to this entry

    ### Chris Hills

    Still not working for The following works, assuming that the base tld always comes first in effective_tld_names.dat:-

    --- 2009-11-24 22:54:21.000000000 +0100
    +++ 2009-11-26 13:27:18.801134912 +0100
    @@ -53,11 +53,12 @@
    domain = ''
    etld = ''

    - for rule in self.rules[tld]:
    + for rule in reversed(self.rules[tld]):
    m = rule.match(hostname)
    if m and > etld:
    domain =[::-1]
    etld =[::-1]
    + break

    if not etld:
    raise Exception('Parse failed')

    ### Daniel

    (Sorry for the bad English)


    thanks for this library!

    Wouldn't it be better to set the default value for "datafile" to None (in __in it__) and to download the data if "datafile" is None?

    I can send you my changes if you want.

    Best regards,

    Add a comment to this post:

    Your name:

    Your email: Email me new comments on this post
      (Your email will not be published on this site, and will only be used to contact you directly with a reply to your comment if needed. Oh, and we'll use it to send you new comments on this post it you selected that checkbox.)

    Your website: