diff --git a/contrib/seeds/generate-seeds.py b/contrib/seeds/generate-seeds.py
--- a/contrib/seeds/generate-seeds.py
+++ b/contrib/seeds/generate-seeds.py
@@ -34,54 +34,58 @@
 
 from base64 import b32decode
 from binascii import a2b_hex
-import sys, os
+import sys
+import os
 import re
 
 # ipv4 in ipv6 prefix
 pchIPv4 = bytearray([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff])
 # tor-specific ipv6 prefix
-pchOnionCat = bytearray([0xFD,0x87,0xD8,0x7E,0xEB,0x43])
+pchOnionCat = bytearray([0xFD, 0x87, 0xD8, 0x7E, 0xEB, 0x43])
+
 
 def name_to_ipv6(addr):
-    if len(addr)>6 and addr.endswith('.onion'):
+    if len(addr) > 6 and addr.endswith('.onion'):
         vchAddr = b32decode(addr[0:-6], True)
-        if len(vchAddr) != 16-len(pchOnionCat):
+        if len(vchAddr) != 16 - len(pchOnionCat):
             raise ValueError('Invalid onion %s' % s)
         return pchOnionCat + vchAddr
-    elif '.' in addr: # IPv4
+    elif '.' in addr:  # IPv4
         return pchIPv4 + bytearray((int(x) for x in addr.split('.')))
-    elif ':' in addr: # IPv6
-        sub = [[], []] # prefix, suffix
+    elif ':' in addr:  # IPv6
+        sub = [[], []]  # prefix, suffix
         x = 0
         addr = addr.split(':')
-        for i,comp in enumerate(addr):
+        for i, comp in enumerate(addr):
             if comp == '':
-                if i == 0 or i == (len(addr)-1): # skip empty component at beginning or end
+                # skip empty component at beginning or end
+                if i == 0 or i == (len(addr) - 1):
                     continue
-                x += 1 # :: skips to suffix
+                x += 1  # :: skips to suffix
                 assert(x < 2)
-            else: # two bytes per component
+            else:  # two bytes per component
                 val = int(comp, 16)
                 sub[x].append(val >> 8)
                 sub[x].append(val & 0xff)
         nullbytes = 16 - len(sub[0]) - len(sub[1])
         assert((x == 0 and nullbytes == 0) or (x == 1 and nullbytes > 0))
         return bytearray(sub[0] + ([0] * nullbytes) + sub[1])
-    elif addr.startswith('0x'): # IPv4-in-little-endian
+    elif addr.startswith('0x'):  # IPv4-in-little-endian
         return pchIPv4 + bytearray(reversed(a2b_hex(addr[2:])))
     else:
         raise ValueError('Could not parse address %s' % addr)
 
+
 def parse_spec(s, defaultport):
     match = re.match('\[([0-9a-fA-F:]+)\](?::([0-9]+))?$', s)
-    if match: # ipv6
+    if match:  # ipv6
         host = match.group(1)
         port = match.group(2)
-    elif s.count(':') > 1: # ipv6, no port
+    elif s.count(':') > 1:  # ipv6, no port
         host = s
         port = ''
     else:
-        (host,_,port) = s.partition(':')
+        (host, _, port) = s.partition(':')
 
     if not port:
         port = defaultport
@@ -90,7 +94,8 @@
 
     host = name_to_ipv6(host)
 
-    return (host,port)
+    return (host, port)
+
 
 def process_nodes(g, f, structname, defaultport):
     g.write('static SeedSpec6 %s[] = {\n' % structname)
@@ -106,13 +111,14 @@
             g.write(',\n')
         first = False
 
-        (host,port) = parse_spec(line, defaultport)
+        (host, port) = parse_spec(line, defaultport)
         hoststr = ','.join(('0x%02x' % b) for b in host)
         g.write('    {{%s}, %i}' % (hoststr, port))
     g.write('\n};\n')
 
+
 def main():
-    if len(sys.argv)<2:
+    if len(sys.argv) < 2:
         print(('Usage: %s <path_to_nodes_txt>' % sys.argv[0]), file=sys.stderr)
         exit(1)
     g = sys.stdout
@@ -126,13 +132,13 @@
     g.write(' * Each line contains a 16-byte IPv6 address and a port.\n')
     g.write(' * IPv4 as well as onion addresses are wrapped inside a IPv6 address accordingly.\n')
     g.write(' */\n')
-    with open(os.path.join(indir,'nodes_main.txt'),'r') as f:
+    with open(os.path.join(indir, 'nodes_main.txt'), 'r') as f:
         process_nodes(g, f, 'pnSeed6_main', 8333)
     g.write('\n')
-    with open(os.path.join(indir,'nodes_test.txt'),'r') as f:
+    with open(os.path.join(indir, 'nodes_test.txt'), 'r') as f:
         process_nodes(g, f, 'pnSeed6_test', 18333)
     g.write('#endif // BITCOIN_CHAINPARAMSSEEDS_H\n')
-            
+
+
 if __name__ == '__main__':
     main()
-