Re: How to run script from interpreter?

2018-02-19 Thread windhorn
On Saturday, February 17, 2018 at 8:50:48 AM UTC-6, Steven D'Aprano wrote: > > For me, the tool I use is a set of re-usable tools: > > - a text editor; > - a system command prompt in a terminal/console window; > - a Python REPL for running code snippets and looking up help(obj). > > Other

Re: How to run script from interpreter?

2018-02-17 Thread Steven D'Aprano
On Fri, 16 Feb 2018 14:18:16 -0800, windhorn wrote about running scripts from the interpreter: [...] > That works, but nothing is very convenient for debugging simple scripts. > If I run the script from a command prompt it works, but I lose all my > other stuff (debugging functions, variables,

Re: How to run script from interpreter?

2018-02-16 Thread Ian Kelly
On Fri, Feb 16, 2018 at 3:18 PM, windhorn wrote: > Yes, it's been covered, but not quite to my satisfaction. > > Here's an example simple script: > > # Very simple script > bar = 123 > > I save this as "foo.py" somewhere Python can find it > import foo bar >

Re: How to run script from interpreter?

2018-02-16 Thread Chris Angelico
On Sat, Feb 17, 2018 at 9:18 AM, windhorn wrote: > Yes, it's been covered, but not quite to my satisfaction. > > Here's an example simple script: > > # Very simple script > bar = 123 > > I save this as "foo.py" somewhere Python can find it > import foo bar >

How to run script from interpreter?

2018-02-16 Thread windhorn
Yes, it's been covered, but not quite to my satisfaction. Here's an example simple script: # Very simple script bar = 123 I save this as "foo.py" somewhere Python can find it >>> import foo >>> bar Traceback (most recent call last): File "", line 1, in NameError: name 'bar' is not defined

Re: How to run script from interpreter?

2014-05-30 Thread Steven D'Aprano
On Fri, 30 May 2014 12:04:27 +1000, Chris Angelico wrote: On Fri, May 30, 2014 at 11:49 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 30 May 2014 10:46:34 +1000, Chris Angelico wrote: On Fri, May 30, 2014 at 10:33 AM, Steven D'Aprano

Re: How to run script from interpreter?

2014-05-30 Thread Chris Angelico
On Fri, May 30, 2014 at 4:20 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: It's on par with creating a file with a name beginning with a hyphen, and then fiddling around with various commands as you try to manipulate it (tip: rm ./-r works); programs will happily interpret -r

Re: How to run script from interpreter?

2014-05-30 Thread Steven D'Aprano
On Fri, 30 May 2014 17:19:00 +1000, Chris Angelico wrote: On Fri, May 30, 2014 at 4:20 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: It's on par with creating a file with a name beginning with a hyphen, and then fiddling around with various commands as you try to manipulate

Re: How to run script from interpreter?

2014-05-30 Thread Chris Angelico
On Fri, May 30, 2014 at 9:27 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: This is why I'm so adamant that, while REPLs may be permitted to introduce *new* syntax which is otherwise illegal to the Python parser, (e.g. like IPython's %magic and !shell commands) they *must not*

Re: How to run script from interpreter?

2014-05-30 Thread Terry Reedy
On 5/30/2014 7:46 AM, Chris Angelico wrote: Hmm. I'm not sure that raises SyntaxError is any less a part of the language's promise than evaluates to twice the value of x is. Of course it is. A real SyntaxError cannot be caught immediately.* When new syntax features are added, breaking the

Re: How to run script from interpreter?

2014-05-30 Thread Steven D'Aprano
On Fri, 30 May 2014 21:46:55 +1000, Chris Angelico wrote: On Fri, May 30, 2014 at 9:27 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: This is why I'm so adamant that, while REPLs may be permitted to introduce *new* syntax which is otherwise illegal to the Python parser,

Re: How to run script from interpreter?

2014-05-30 Thread Chris Angelico
On Sat, May 31, 2014 at 5:28 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Before you ask, there is no absolutely hard and fast line between shell feature and Python code, but the more closely your shell features resemble Python code, the harder it will be for users (power or

Re: How to run script from interpreter?

2014-05-29 Thread Mark H Harris
On 5/28/14 10:22 PM, Steven D'Aprano wrote: If you want to use python as a shell-glue you can try using system. from os import system def function_name([parms]) blah blah rc = system(your_script_name) os.system is cool for quick and dirty calls to an external command.

Re: How to run script from interpreter?

2014-05-29 Thread Steven D'Aprano
On Thu, 29 May 2014 15:26:37 -0500, Mark H Harris wrote: I think the IDLE REPL should have a system shell mode. What say you? I don't use IDLE, so I don't really care what you do to it. But speaking generally, -1 on that. IDLE is primarily aimed at beginners, and beginners have enough trouble

Re: How to run script from interpreter?

2014-05-29 Thread Chris Angelico
On Fri, May 30, 2014 at 10:33 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: (By the way, ; won't work for a Python shell, because ;spam already is valid Python syntax: it's an empty statement followed by the statement spam, separated by a semicolon.) That's not really a

Re: How to run script from interpreter?

2014-05-29 Thread Steven D'Aprano
On Fri, 30 May 2014 10:46:34 +1000, Chris Angelico wrote: On Fri, May 30, 2014 at 10:33 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: (By the way, ; won't work for a Python shell, because ;spam already is valid Python syntax: it's an empty statement followed by the statement

Re: How to run script from interpreter?

2014-05-29 Thread Chris Angelico
On Fri, May 30, 2014 at 11:49 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 30 May 2014 10:46:34 +1000, Chris Angelico wrote: On Fri, May 30, 2014 at 10:33 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: (By the way, ; won't work for a Python shell,

Re: How to run script from interpreter?

2014-05-28 Thread onlyvinish
On Friday, January 19, 2001 1:22:23 AM UTC+5:30, Rolander, Dan wrote: What is the best way to run a python script from within the interpreter? What command should I use? Thanks, Dan try using execfile(filename) -- https://mail.python.org/mailman/listinfo/python-list

Re: How to run script from interpreter?

2014-05-28 Thread Terry Reedy
On 5/28/2014 3:44 AM, onlyvin...@gmail.com wrote: On Friday, January 19, 2001 1:22:23 AM UTC+5:30, Rolander, Dan wrote: What is the best way to run a python script from within the interpreter? What command should I use? Thanks, Dan try using execfile(filename) or in 3.x with open(filename)

Re: How to run script from interpreter?

2014-05-28 Thread Mark H Harris
On 5/28/14 2:44 AM, onlyvin...@gmail.com wrote: On Friday, January 19, 2001 1:22:23 AM UTC+5:30, Rolander, Dan wrote: What is the best way to run a python script from within the interpreter? What command should I use? try using execfile(filename) What type of script? python? bash?

Re: How to run script from interpreter?

2014-05-28 Thread Steven D'Aprano
On Wed, 28 May 2014 11:39:23 -0500, Mark H Harris wrote: On 5/28/14 2:44 AM, onlyvin...@gmail.com wrote: On Friday, January 19, 2001 1:22:23 AM UTC+5:30, Rolander, Dan wrote: What is the best way to run a python script from within the . interpreter?