On 2/10/07, Ayaz Ahmed Khan <[EMAIL PROTECTED]> wrote: >> class Vuln: >> >> class VulnInfo(Vuln): >> >> class VulnDiscuss(Vuln): >> >> def main(url): >> vuln_class = ['Info', 'Discuss'] >> vuln = Vuln(url) >> vuln._parse() >> for link in vuln.get_link(): >> i = VulnInfo(link) >> i._parse() >> d = VulnDiscuss(link) >> d._parse() >> >> >> Is there a way to get references to VulnInfo and VulnDiscuss objects
In addition to what other people has suggested: - Use some kind of registry: register("Vuln", Vuln, VulnInfo, VulnDiscuss) (a dictionary would do) and then look up by name - If all three classes are contained inside the same module, look up them by name into globals: InfoClass = globals()["%sInfo" % self.__class__.__name__] (assuming self is an instance of Vuln, this would give you the VulnInfo class) - Replace your line: vuln_class = ['Info', 'Discuss'] with vuln_class = [VulnInfo, VulnDiscuss] As you see, there are many ways to do that - choose what better fits your needs. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list