Python compile
Aug 01, 2014 in Python
From: http://askubuntu.com/questions/324871/how-to-compile-a-python-file
python -m py_compile fileA.py fileB.py fileC.py
Aug 01, 2014 in Python
From: http://askubuntu.com/questions/324871/how-to-compile-a-python-file
python -m py_compile fileA.py fileB.py fileC.py
Oct 20, 2010 in Python
The “main” script:
# ttest.py import threading import someclass csc = someclass.SomeClass() csc_thread = threading.Thread(target=csc.run,args=()) csc_thread.start()
The class used to run in a thread:
# someclass.py class SomeClass: def __init__(self): print "init" def run(self): # import pdb # pdb.set_trace() # trigger debugger for ix in range(1,10): print "run %d" % ix
To run it:
python [-m pdb] ttest.py
Oct 16, 2010 in Python
File “mod_loader.py” :
# file: mod_loader.py mod_name = "pkg.mod_loadee" # Get module object (class is stored in a module) mod_obj = __import__(mod_name, globals(), locals(), ['']) print ">> %s" % mod_obj # Get class class_obj = mod_obj.getClass() print ">> %s" % class_obj # Create instance from class object class_inst = class_obj() # invoke method class_inst.testme()
in folder “pkg”, make file “mod_loadee.py” :
class Loadee: def __init__(self): print "Loadee.init" def testme(self): print "Loadee.testme" def getClass(): return Loadee
run it:
python mod_loader.py
do not forget the “./pkg/__init__.py” to make the folder a package .
.