Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43045 > unrolled thread

Interactive development in Python à la Smalltalk?

Started byBienlein <jeti789@web.de>
First post2013-04-08 01:33 -0700
Last post2013-04-08 15:01 -0400
Articles 4 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  Interactive development in Python à la Smalltalk? Bienlein <jeti789@web.de> - 2013-04-08 01:33 -0700
    Re: Interactive development in Python à la Smalltalk? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-08 09:27 +0000
    Re: Interactive development in Python à la Smalltalk? "Colin J. Williams" <cjw@ncf.ca> - 2013-04-08 08:26 -0400
    Re: Interactive development in Python à la Smalltalk? Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-08 15:01 -0400

#43045 — Interactive development in Python à la Smalltalk?

FromBienlein <jeti789@web.de>
Date2013-04-08 01:33 -0700
SubjectInteractive development in Python à la Smalltalk?
Message-ID<b72b1403-ade8-4524-94c3-19043ee64a1f@googlegroups.com>
Hello,

I'm absolutely new to Python, just looked at the language description for the first time. The first thought that came to my mind was whether you can program  in Python in an interactive programming style, i.e. I can change code in the debugger which becomes immediately effective (no edit-compile loop) and I can also send messages to objects visible inside the debugger. 

Then Python could become my replacemenet for my dearly missed Smalltalk, which to my great grief meanwhile really has become quite dead, I fear. In Smalltalk you can open up an inspector window (e.g. you don't have to get into debug mode), inspect objects in it and evaluate code in it, send messaages to objects. I guess this cannot be done in Python out of the box. But if changes made in the debugger became immediately effective, this would be interactive enough for my purposes.

Thanks, Bienlein

[toc] | [next] | [standalone]


#43051

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-04-08 09:27 +0000
Message-ID<51628d94$0$29868$c3e8da3$5496439d@news.astraweb.com>
In reply to#43045
On Mon, 08 Apr 2013 01:33:13 -0700, Bienlein wrote:

> Hello,
> 
> I'm absolutely new to Python, just looked at the language description
> for the first time. The first thought that came to my mind was whether
> you can program  in Python in an interactive programming style, i.e. I
> can change code in the debugger which becomes immediately effective (no
> edit-compile loop) and I can also send messages to objects visible
> inside the debugger.

Out of the box, Python comes with an extremely powerful interactive 
environment. Just launch Python from the command prompt with no 
arguments, and it will open an interactive interpreter that allows you to 
enter commands, hit enter, and have them executed.

I strongly recommend you work through at least the beginning of the 
tutorial, and get used to the interactive interpreter. Here's the one for 
Python 2:

http://docs.python.org/2/tutorial/index.html

and version 3:

http://docs.python.org/3/tutorial/index.html



If that's not enough for you, there are third-party Python interpreters 
that do much more, such as BPython, IPython and DreamPie.

http://bpython-interpreter.org/screenshots/

http://ipython.org/index.html 

http://www.dreampie.org/.

IPython will be especially familiar to those used to Mathematica.


You can't quite edit code in live objects -- code is compiled to byte-
code for a virtual machine, and you cannot edit that -- but you can 
easily redefine objects, including functions and methods, on the fly.


py> class Test(object):
...     def method(self, arg):
...             print "argument received:", arg
... 
py> 
py> t = Test()
py> t.method(23)
argument received: 23
py> 
py> def method(self, arg):
...     print "argument received:", arg+1000
... 
py> Test.method = method
py> t.method(23)
argument received: 1023



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#43067

From"Colin J. Williams" <cjw@ncf.ca>
Date2013-04-08 08:26 -0400
Message-ID<5162B780.5050101@ncf.ca>
In reply to#43045
On 08/04/2013 4:33 AM, Bienlein wrote:
> Hello,
>
> I'm absolutely new to Python, just looked at the language description for the first time. The first thought that came to my mind was whether you can program  in Python in an interactive programming style, i.e. I can change code in the debugger which becomes immediately effective (no edit-compile loop) and I can also send messages to objects visible inside the debugger.
>
> Then Python could become my replacemenet for my dearly missed Smalltalk, which to my great grief meanwhile really has become quite dead, I fear. In Smalltalk you can open up an inspector window (e.g. you don't have to get into debug mode), inspect objects in it and evaluate code in it, send messaages to objects. I guess this cannot be done in Python out of the box. But if changes made in the debugger became immediately effective, this would be interactive enough for my purposes.
>
> Thanks, Bienlein
>
If you are using Windows, PyScripter is a good choice.

I understand that, with Linux, it can also be used with Wine.  I haven't 
tried that.

Colin W.

[toc] | [prev] | [next] | [standalone]


#43088

FromTerry Jan Reedy <tjreedy@udel.edu>
Date2013-04-08 15:01 -0400
Message-ID<mailman.300.1365447679.3114.python-list@python.org>
In reply to#43045
On 4/8/2013 4:33 AM, Bienlein wrote:
> Hello,
>
> I'm absolutely new to Python, just looked at the language description
> for the first time. The first thought that came to my mind was
> whether you can program  in Python in an interactive programming
> style, i.e. I can change code in the debugger which becomes
> immediately effective (no edit-compile loop) and I can also send
> messages to objects visible inside the debugger.

The CPython interpreter has both a 'batch' mode (run code in a file) and 
an interactive mode (run code typed in response to a prompt). It also 
has a '-i' option to run code in batch mode and then switch to 
interactive mode so one can interrogate visible objects and call functions.

The Idle IDE has editor windows linked to an interactive shell. When you 
run code in the editor window, it saves and runs it with the -i option 
so you can interactive with the results in the Shell. Compiling edited 
text to bytecode is typically so fast (well under a second) as to not be 
an issue.

> Then Python could become my replacemenet for my dearly missed
> Smalltalk, which to my great grief meanwhile really has become quite
> dead, I fear. In Smalltalk you can open up an inspector window (e.g.
> you don't have to get into debug mode), inspect objects in it and
> evaluate code in it, send messaages to objects. I guess this cannot
> be done in Python out of the box. But if changes made in the debugger
> became immediately effective, this would be interactive enough for my
> purposes.

Idle also has a debugger window that does some of that, though it works 
better on non-Windows OSes. I have never actually used it.

---
Terry Jan Reedy

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web