oop - Classes, methods, and polymorphism in Python -


I created a module prototype in Python for the purpose of creating complex timer schedules. Emulating the class prototype timer objects, each repeat with your waiting time, timers and other repetitive objects to an entire building or timer, and again on a schedule class. The construction can be as complex as it can be and it should be flexible.

Each of these three classes has the .run () method, which allows the entire program to go through. Whatever the class, the .run () method either runs a timer, a repeating group or schedule for a certain number of iterations.

Is this polynomial-oriented approach or stupid? With other appropriate methods, should I consider building a versatile utility which allows all building blocks to be desired together in a complicated manner simultaneously?

Thank you!

Module Code:

  ###################### Importing the module from import time, Sleep ###################### Classroom Definition Class Timer: "Timer Object" with Period. " "Diaf __int __ (self, period): self.duration = term def run (self): print"% i seconds of waiting "% self.duration wait for (Selfkduration) Chime () class repeat:" "" Repetition Repeat items grouped to a certain number. "" def __init __ (self, objects = [], rep = 1): self.rep = representatives self.objects = object def run (self): print "% i times in the repetitive group "% self.rep for I xrange (self.rep): Self.objects group: group.run () class Sched Ule:" "" timer and priced iterations . May be redundant with grade repetition "" "Def __init __ (self, schedule = []): self.schedule = schedule Diarf (to run itself) to the group self.schedule: group.run () # ######################### Define the Def Def (Duration): "Wait" for a few seconds "Time" = Time () + float (period) to # minutes # minutes * # 60 Smay_dif = Smay_and - time () while time_diff & gt; 0: sleep (1) time_diff = time_end - time () def chime (): print "Ding!"  

It is called and It is used in Python all the time .


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -