how to run another file inside current file?

Kevin Xi kevin.xgr at gmail.com
Sat May 18 07:15:14 EDT 2013


Hi,
It's better to specify version of python you work with. I know nothing
about python 3 but in python 2 you can do this with `exec`. Example:

> f = file('otherFile.py')
> exec f

For more, read the doc:
http://docs.python.org/2.7/reference/simple_stmts.html#the-exec-statement
HTH


                                                   Kevin

2013/5/18 Avnesh Shakya <avnesh.nitk at gmail.com>

> hi,
>    I want to run a another file inside a ached.add_cron_job(..). how is it
> possible, please help me, I have a file otherFile.py for execution inside
> current file.
> I know it is very easy question but i m unable to get anything, please
> help me.
> example --
>
> import otherFile
> from apscheduler.scheduler import Scheduler
> sched = Scheduler()
> sched.start()
>
> def job_function():
>     # Can I here add that file for execution, Or can i add that file
> directly inside cron?
>
> sched.add_cron_job(job_function, month='1-12', day='1-31',
> hour='0-23',minute='44-49')
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
让我们忠于理想,让我们面对现实。
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130518/46baf60c/attachment.html>


More information about the Python-list mailing list