class or function

Bart Nessux bart_nessux at hotmail.com
Wed Feb 4 11:05:47 EST 2004


What is the significant difference between using a class, like this:

class threaded_ddos(Thread):
    def run(self):
       pass
if __name__ == '__main__':

Or, using functions, like this:

def threaded_ddos(Thread):
    def run():
       pass
    run()
threaded_ddos()

I'm trying to better understand this difference. I tend to use functions 
that call functions instead of classes that contain functions which I 
can import. To me, functions within functions are simpler. The results 
of either method are the same, but I must ask which is preferred and 
why? Are both OK depending on the application? I don't do inheritance 
type stuff.




More information about the Python-list mailing list