Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to run another file inside current file?

16 views
Skip to first unread message

Avnesh Shakya

unread,
May 18, 2013, 12:48:54 AM5/18/13
to
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')

fjc...@gmail.com

unread,
May 18, 2013, 6:32:54 AM5/18/13
to Avnesh Shakya, pytho...@python.org
subprocess?

发自我的小米手机

Avnesh Shakya <avnes...@gmail.com>编写:

>--
>http://mail.python.org/mailman/listinfo/python-list

Kevin Xi

unread,
May 18, 2013, 7:15:14 AM5/18/13
to Avnesh Shakya, pytho...@python.org
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

HTH

                                                                                                                               Kevin

2013/5/18 Avnesh Shakya <avnes...@gmail.com>



--
让我们忠于理想,让我们面对现实。

Terry Jan Reedy

unread,
May 18, 2013, 12:39:16 PM5/18/13
to pytho...@python.org
On 5/18/2013 7:15 AM, Kevin Xi wrote:
> Hi,
> It's better to specify version of python you work with.

Absolutely.


I know nothing
> about python 3 but in python 2 you can do this with `exec`. Example:
>
> > f = file('otherFile.py')
> > exec f

Py 2 has execfile that does the above. Py 3 do as above except that exec
is a function.

with open('otherfile.py') as f:
exex(f)
0 new messages