To associate a icon with your extension you will have to create a registry entry for that and a icon associated with a extension doesn't mean anything unless you associate some program to open it with you, that too you can do in registry e.g
Create an entry for your program's icon name, e.g.
HKCU\Software\Classes\myprog.file.xyz
under HKCU\Software\Classes\myprog.file.xyz create enteries for default icon
HKCU\Software\Classes\myprog.file.xyz\DefaultIcon
here you can give path to an icon or to your app and icon will be taken from resource
Create a entry for Open and other commands if you want your extension to open correctly
e.g. HKCU\Software\Classes\myprog.file.xyz\Shell\Open\Command
and enter path to your program or any other program
similarly you can add command for view/print etc
Now you have to tell registry that extension .xyz should use info from HKCU\Software\Classes\myprog.file.xyz
so create an entry
HKCU\Software\Classes.xyz = myprog.file.xyz
Actually if you wish you can directly put 1-3 in HKCU\Software\Classes.xyz, but this redirection is a better way of doing things.
because now you can simply assign myprog.file.xyz to many extrnsions e.g. .xxx, .yyy or .zzz etc
Now using python module _winreg (http://docs.python.org/library/_winreg.html) you can create all these enteries programtically.
e.g. this script will set xyz to python icon
from _winreg import *
xyzKey = CreateKey(HKEY_CLASSES_ROOT, ".xyz")
SetValue(xyzKey, None, REG_SZ, "MyTest.xyz")
CloseKey(xyzKey)
myTestKey = CreateKey(HKEY_CLASSES_ROOT, "MyTest.xyz")
iconKey= CreateKey(myTestKey, "DefaultIcon")
CloseKey(myTestKey)
SetValue(iconKey, None, REG_SZ, "D:\\Python25\\python.exe")
CloseKey(iconKey)