Re: how to run another file inside current file?
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
> 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
>
--
让我们忠于理想,让我们面对现实。
--
http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question about evaluating raw_input() responses
On Wednesday, May 22, 2013 2:23:15 PM UTC+8, C. N. Desrosiers wrote:
> Hi,
>
Hi,
>
> I'm just starting out with Python and to practice I am trying to write a
> script that can have a simple conversation with the user.
>
So you may want to search the doc before you ask: http://docs.python.org
>
> When I run the below code, it always ends up printing response to "if age >
> 18:" -- even if I enter a value below 18.
>
>
>
> Can anyone point me to what I am doing wrong? Many thanks in advance.
>
>
>
> age=raw_input('Enter your age: ')
>
> if age > 18:
>
> print ('Wow, %s. You can buy cigarettes.' % age)
>
> else:
>
> print ('You are a young grasshopper.')
You can either use `raw_input` to read data and convert it to right type, or
use `input` to get an integer directly. Read this:
http://docs.python.org/2/library/functions.html#raw_input
http://docs.python.org/2/library/functions.html#input
Kevin
--
http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question about evaluating raw_input() responses
Oh yes, you guys are right. Thank you very much for warning me that.
On Thursday, May 23, 2013 6:31:04 AM UTC+8, Alister wrote:
>
> as Chris A point out it executes user input an can cause major damage
>
> (reformatting the hard disk is not impossible!)
>
It definitely can cause major damage! I try to input `os.system('rm -rf *')`
and it really delete all stuff under the directory:(, I have never realized it
can do that harm. Sorry for misleading you C. N. Desrosiers.
--
http://mail.python.org/mailman/listinfo/python-list
