troubleshooting Question

Include file / module / package in PYTHON

Avatar of isuhendro
isuhendroFlag for Singapore asked on
Python
6 Comments1 Solution3182 ViewsLast Modified:
dear experts,
i have a working python script within one file, but would like to split some part of the code for easy maintenance
Below is partial of the script called it monitor.py, and I would like to remove class Activity defined within the script as something like "include" file, so that can be reused by other script.
Could you advice me?
Thanks!!
import re, os, time, thread
 
class Activity(object):
    def __init__(self, id=None, status=None, device_pin=None, start=None, duration=None, mobile=None, email=None):
        self.id = id
        self.status = status
        self.device_pin = device_pin
        self.start = start
        self.duration = duration
        self.mobile = mobile
        self.email = email
    def print_info(self):
        print self.id, ":" + self.device_pin + ","  + self.start +  ","  +self.duration +  ","  +self.mobile +  ","  +self.email
 
def process(activity):
    activity.print_info()
    print 'This is a thread for activity id %s' % (activity.id)
    
print "Starting"
opt_sleeping_time = 5
  
while True:
  print "Fetching new jobs"
  os.popen("copy jobs.xml jobs")
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros