[Tutor] When to use a class
Eric Lake
ericlake at ubuntu.com
Mon Sep 17 18:44:09 CEST 2007
I am still trying to understand when to use a class and when not to. All
of the coding that I have done in the past (Python, Perl) has been
procedural / functional. I would really like to do more OOP but I am not
really sure when I need it.
I have the following code. Is there any way that it would benefit from
using a class?
<code>
#!/usr/bin/env python
import string
import _winreg
import sys
compName = sys.argv[1]
x = _winreg.ConnectRegistry(compName,_winreg.HKEY_LOCAL_MACHINE)
y = _winreg.OpenKey(x,
r"SOFTWARE\Intel\LANDesk\VirusProtect6\CurrentVersion")
avParent = _winreg.QueryValueEx(y,"Parent")[0]
_winreg.CloseKey(y)
print "Computer: %s \tAV Parent: %s" % (compName,avParent)
</code>
--
Thanks
Eric Lake
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: Digital signature
Url : http://mail.python.org/pipermail/tutor/attachments/20070917/ec0c8efa/attachment-0001.pgp
More information about the Tutor
mailing list