Hi Michael,

Michael Wexler wrote:

> Hi, I've been trying various tutorial things in the "interactive
> window" of Pythonwin and I'm having trouble with simple things in the
> IW; these all work as saved script files.
>
> I've read the help file
> (mk:@MSITStore:C:\Python24\Doc\ActivePython24.chm::/pywin32/html/pythonwin/doc/guienvironment.html)
> about the Interactive window, and it seems that what I am doing should
> work... but I'm just not sure.
>
> For example, try the following script:
>
> print "Hello"
> print "Hello, again"
>
> I type the first line, and even remember to press SHIFT-Enter.  Next
> line appears with "..." as prompt.  I then type the next line, and
> press just enter.


When you typed these two statements into a script file they were both at the same block level (left "margin") because each is a separate, full statement. If the second line were a continuation of the statement in the first line then you would use Shift-Enter and indent it to the second block level. For interactive testing you would use just ENTER after each line, so the session would look like this:

>>> print "Hello"
Hello
>>> print "Hello, again"
Hello, again
>>>

with the outputs interspersed with the statements. A small example of statement continuation:

>>> for i in (1, 2, 3):
...     print "i = ", i
...     print "i2 = ", i * i
...
i =  1
i2 =  1
i =  2
i2 =  4
i =  3
i2 =  9
>>>

The last continuation line "... " indicates the end of this "block", and the full statement is then sent to the interpreter. The use of indentation to indicate block level is a property of Python rather than your specific editor, so you need to check the basic Python documentation for this.

Enjoy!
Wayne

> I only see the first Hello!
>
> 2nd try: Same as above, but press Shift-Enter after the 2nd line. Blank line with ..., just press enter. Just first Hello again.
>
> What am I doing wrong?  Can the IW not handle multi-line "python
> snippets"?
>
> Thanks, Michael the Beginner
> _______________________________________________
> ActivePython mailing list
> ActivePython@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython
>

_______________________________________________
ActivePython mailing list
ActivePython@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython

Reply via email to