Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45492 > unrolled thread
| Started by | Avnesh Shakya <avnesh.nitk@gmail.com> |
|---|---|
| First post | 2013-05-17 21:48 -0700 |
| Last post | 2013-05-18 12:39 -0400 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
how to run another file inside current file? Avnesh Shakya <avnesh.nitk@gmail.com> - 2013-05-17 21:48 -0700
Re: how to run another file inside current file? Kevin Xi <kevin.xgr@gmail.com> - 2013-05-18 19:15 +0800
Re: how to run another file inside current file? Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-18 12:39 -0400
| From | Avnesh Shakya <avnesh.nitk@gmail.com> |
|---|---|
| Date | 2013-05-17 21:48 -0700 |
| Subject | how to run another file inside current file? |
| Message-ID | <67c4dd92-7e6a-4955-850b-0c21c2708e05@googlegroups.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')
[toc] | [next] | [standalone]
| From | Kevin Xi <kevin.xgr@gmail.com> |
|---|---|
| Date | 2013-05-18 19:15 +0800 |
| Message-ID | <mailman.1798.1368875743.3114.python-list@python.org> |
| In reply to | #45492 |
[Multipart message — attachments visible in raw view] — view raw
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@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
>
--
让我们忠于理想,让我们面对现实。
[toc] | [prev] | [next] | [standalone]
| From | Terry Jan Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2013-05-18 12:39 -0400 |
| Message-ID | <mailman.1807.1368895205.3114.python-list@python.org> |
| In reply to | #45492 |
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)
> For more, read the doc:
> http://docs.python.org/2.7/reference/simple_stmts.html#the-exec-statement
> HTH
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web