Coder Social home page Coder Social logo

donkirkby / live-py-plugin Goto Github PK

View Code? Open in Web Editor NEW
284.0 12.0 57.0 120.73 MB

Live coding in Python with PyCharm, Emacs, Sublime Text, or even a browser

Home Page: https://donkirkby.github.io/live-py-plugin

License: MIT License

Emacs Lisp 4.43% Python 55.71% Java 20.29% HTML 0.38% CSS 0.30% JavaScript 18.42% Shell 0.21% Dockerfile 0.25%
python emacs-mode emacs pycharm-plugin live-coding livecoding livecode sublime-text pycharm gnu-emacs

live-py-plugin's Introduction

Live Coding in Python

Python Build Status HTML Build Status Code Coverage OpenSSF Best Practices PyCharm downloads Emacs downloads Sublime downloads space-tracer downloads Supported Python versions DOI

Visualize your Python code while you type it in PyCharm, Emacs, Sublime Text, or even your browser.

Live coding tightens the feedback loop between making a change to your code and seeing the behaviour change. As you type your code, it will run over and over, showing a visualization of the program state, a matplotlib graph, a Pillow image, or turtle graphics. If you make a mistake, you'll immediately see the problem and where it went wrong.

To see how to use one of the Live Coding in Python plugins, watch the demo video or read the getting started pages for PyCharm, Emacs, or Sublime Text. Want to try it without installing anything? Try the browser version. You can also try Space Tracer, the command-line tool that trades time for space when you debug. You might also find some useful examples in the tools folder. To learn more, read about how it works.

Screenshot of a star diagram

Special thanks to James Davies for contributing the Sublime Text support, to Antti Kaihola and Christoph Paulik for contributing the Emacs support, and to Brecht Willems for the idea of flag tutorials. Thanks to all the contributors for helping in all kinds of ways, and thanks to JetBrains for the free PyCharm and IDEA licenses.

If you like this project, check out some of my other projects.

Feature Comparison

So far, the Emacs mode seems to be the most popular way to use live coding in Python, and the PyCharm plugin has the most features. The browser version might be the best for students, because it has tutorials and doesn't need to be installed.

Feature PyCharm Emacs Sublime browser space_tracer
variable assignments Y Y Y Y Y
looping Y Y Y Y Y
function calls Y Y Y Y Y
errors and exceptions Y Y Y Y Y
print function Y Y Y Y Y
unit tests Y Y Y Y
turtle graphics Y Y
matplotlib preview Y Y
pyglet preview Y Y
tutorials and goals Y

If you find the project useful, help us make it better.

Installing the PyCharm plugin

This assumes you already have PyCharm installed, you have configured a Python interpreter, and you can run a Python script normally.

  1. From the File menu, choose Settings....
  2. Click on the Plugins section.
  3. Click the Browse Repositories... button.
  4. Type live coding in the search box, and click on the "Live Coding in Python" entry in the list below.
  5. Click the green Install button on the right.
  6. Click the Restart PyCharm button.
  7. Close all the dialog boxes by clicking OK, then let PyCharm restart when it asks.
  8. Open a Python file.
  9. Run the Python file normally, as a script or a unit test.
  10. With the same run configuration selected in the drop down, choose Start Live Coding from the Run menu.

Uninstalling the PyCharm plugin

  1. From the File menu, choose Settings....
  2. Click on the Plugins section.
  3. In the list of plugins, click on Live Coding in Python.
  4. Click the Uninstall button on the right.
  5. Click the Restart PyCharm button.
  6. Close all the dialog boxes by clicking OK, then let PyCharm restart.

Installing the Emacs mode

It's probably easiest to use the MELPA package archive, as described in this section, but the next section gives instructions for installing without MELPA.

  1. Install GNU Emacs if you don't already have it.
  2. Install MELPA. You probably want to follow the instructions for the stable version, instead of the default bleeding-edge version.
  3. Launch the package installer with M-x package-list-packages.
  4. Find the package with C-s live-py-mode. If you can't find it, run M-x package-refresh-contents, and try again.
  5. Mark the package to install with i, then execute the installation with x.
  6. Open any Python file, and activate live-py-mode with M-x live-py-mode. You should see an extra window on the right that shows the results of running your code.
  7. Type C-h m and scroll down to the Live-Py section to see all the advanced features that let you run other versions of Python or drive your live coding from another script or a unit test.

Installing the Emacs mode without MELPA

  1. Install GNU Emacs if you don't already have it.

  2. Clone the latest version of the live-py Emacs mode:

     git clone https://github.com/donkirkby/live-py-plugin.git
    
  3. Copy the Emacs Lisp file and the supporting Python files into a directory which is in your Emacs load-path. For example:

     cd live-py-plugin
     mkdir -p ~/.emacs.d/packages
     cp emacs-live-py-mode/live-py-mode.el plugin/PySrc/space_tracer ~/.emacs.d/packages
    

    Add ~/.emacs.d/ to your load-path in ~/.emacs.d/init.el or ~/.emacs:

     (add-to-list 'load-path "~/.emacs.d/packages")
    
  4. Load the Lisp library in your ~/.emacs.d/init.el or ~/.emacs:

     (require 'live-py-mode)
    
  5. Restart Emacs.

  6. Open any Python file, and activate live-py-mode with M-x live-py-mode. You should see an extra window on the right that shows the results of running your code.

  7. Type C-h m and scroll down to the Live-Py section to see all the advanced features that let you run other versions of Python or drive your live coding from another script or a unit test.

Uninstalling the Emacs mode

If you installed with MELPA, just use it to uninstall. If not, follow these steps:

  1. Remove the files you copied into ~/.emacs.d/:
  2. Revert additions to ~/.emacs.d/init.el or ~/.emacs.
  3. Restart Emacs.

Installing the Sublime Text plugin

It's easiest to install from package control, but you can find a manual method in the CONTRIBUTING file.

  1. Install package control.
  2. Open the command palette by typing Ctrl+Shift+P.
  3. Type "Package" and then select Package Control: Install Package.
  4. Start typing "Live Coding in Python" and select it when it appears in the list.
  5. When it finishes installing, you should see a new "Live Coding" menu.
  6. Live coding should now work for simple scripts.
  7. Navigate to Preferences -> Package settings -> Live Coding.
  8. Set the path to your preferred Python executable, particularly if you want to use a virtual environment. The default is python.
  9. Save and close this pane.
  10. Open or create a Python file.
  11. Navigate to Live Coding -> Start
  12. This should bring up a new pane on the right with the live coding display.
  13. Begin typing in the left pane and see the code trace results on the right.

Uninstalling the Sublime Text plugin

  1. Open Sublime Text 3.
  2. Open the command palette by typing Ctrl+Shift+P.
  3. Type "Package" and then select Package Control: Remove Package.
  4. Start typing "Live Coding in Python" and select it when it appears in the list.

live-py-plugin's People

Contributors

akaihola avatar brandm avatar btws2 avatar celeritascelery avatar cipharius avatar cpaulik avatar dalum avatar dependabot-preview[bot] avatar dependabot[bot] avatar derfies avatar donkirkby avatar evelyndai avatar fabioz avatar jayvdb avatar lizardstarks avatar marascax avatar mtkalms avatar purcell avatar salvor7 avatar smolynsf avatar step-security-bot avatar syohex avatar tj-26 avatar udaykharatmol avatar zhenglinj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

live-py-plugin's Issues

Local module imports are not found by the livecoding

I've got a package with a module "Tools", which is imported from another module in the Package with

from Tools import *

Running it in eclipse works fine, but the live coding output says

ImportError: No module named Tools

Show result of loop-condition or if-condition in output

enhancement: (I believe I can't set labels)

I'd like to see the result of a loop condition in the output.

def p(msg):
    print msg

a = 4
b = 5

if a < b:
    p("yes")
else:
    p("no")

Desired output:

msg = 'yes'
print 'yes'

a = 4
b = 5

True

Actual output:

msg = 'yes'
print 'yes'

a = 4
b = 5

Although it's usually not impossible to trace the flow of the program through its subsequent output, it would be easier to see it immediately. Perhaps it would even be possible to output some information for every line.
For example, the code

p("yes")

could just output

p("yes")

to signify that that is what was done on that line, even though no variable assignment too place. However, the conditional statements are of a higher priority.

Tracing code traces the live-py code

Here's an example that shows how the user's code is drowned out by the live-py code. It never even gets to the foo() method before it hits the message limit.

import sys                                          | RuntimeError: live coding message limit exceeded 
                                                    | 
                                                    | 
def traceit(frame, event, arg):                     | event = 'call' arg = None                   | event = 'line' arg = None                   | event = 'line' arg = None       | event = 'call' arg = None                   | event = 'line' arg = None                   | event = 'line' arg = None       ...(trimmed)
    location = frame.f_code.co_name, frame.f_lineno | location = ('record_call', 125)             | location = ('record_call', 131)             | location = ('record_call', 133) | location = ('record_call', 125)             | location = ('record_call', 131)             | location = ('record_call', 133) ...(trimmed)
    return traceit                                  | return <function traceit at 0x7f6887a481b8> | return <function traceit at 0x7f6887a481b8> |                                 | return <function traceit at 0x7f6887a481b8> | return <function traceit at 0x7f6887a481b8> | return <function traceit at 0x7f...(trimmed)
                                                    | 
                                                    | 
def foo(x):                                         | x = 2 
    return x + 3                                    | return 5 
                                                    | 
sys.settrace(traceit)                               | 
try:                                                | 
    x = foo(2)                                      | x = 5 
finally:                                            | 
    sys.settrace(None)                              | 

Suggested fix: try to detect when sys.settrace is called, and put a wrapper around it. The wrapper only calls the user's trace method when the frame is not in the live-py code.

Live Coding menu item not shown

If a python file is not the first file open when you start Eclipse, then the Live Coding menu item is not available in the PyDev menu, even after you open a python file.

Syntax error shouldn't clear display

Currently, a syntax error will wipe out the display, so typing a new line of code often wipes out the current state.

  • Just leave the display untouched when a syntax error occurs.
  • Display a red highlight or something where the syntax error occurs?

Display problems in Eclipse Juno

This problem was reported by a user via e-mail. Thanks for the bug report and suggested fix!

(screen is split in two: first half blank, second half contains the editor and live-display output)

After debugging a couple of hours (I have little Java experience and no experience writing Eclipse Plugins) I traced the problem down to the parent of the Splitter containing the editor and live-display widgets. When setting parent layout to Grid the code editor moves to the left and the big gray space on the left of it disappears.

Here's the changes I did (probably needs more work to keep compatibility with older versions of Eclipse):

$ git diff -p --no-ext-diff plugin/src/live_py/LiveCodingAnalyst.java
diff --git a/plugin/src/live_py/LiveCodingAnalyst.java b/plugin/src/live_py/LiveCodingAnalyst.java
index df44be4..2a8c026 100644
--- a/plugin/src/live_py/LiveCodingAnalyst.java
+++ b/plugin/src/live_py/LiveCodingAnalyst.java
@@ -31,6 +31,7 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.osgi.framework.Bundle;
@@ -111,8 +112,14 @@ public class LiveCodingAnalyst {
         * @return The new control that the editor can be created in.
         */
        public Object createPartControl(Composite parent) {
-               splitter = new Splitter(parent, SWT.HORIZONTAL);

+               parent.setLayout(new GridLayout());
+               parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));             
+
+               splitter = new Splitter(parent,SWT.HORIZONTAL);
+               splitter.setLayout(new FillLayout());
+               splitter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));           
+
                Composite editorContent = new Composite(splitter, SWT.NONE);
                editorContent.setLayout(new FillLayout());
                GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);

Tested on:

  • Eclipse Juno:
    Eclipse for Mobile Developers
    Version: Juno Service Release 2
    Build id: 20130225-0426
  • Aptana:
    Aptana Studio 3, build: 3.4.0.201304151603

Gracefully degrade if Tkinter is not installed

I tried to run with Python 3.4, and it failed silently. When I ran in debug mode, I saw this error:

ImportError: No module named '_tkinter', please install the python3-tk package

  • Either make this kind of exception visible to the user, or create a separate issue: #108.
  • Show program state, but disable turtle view when Tkinter is unavailable. (Actually, turtle view doesn't require Tkinter.)
  • Add Python 3.3 and 3.4 to tox.ini. They don't work now, because the dead snakes versions of Python don't include Tkinter.

Exceptions displayed in final frame of a recursive call.

If you make a recursive call and throw an exception, then the exceptions aren't displayed properly as the stack unwinds. For example:

def f(n):
    x = 1.0 / n
    y = f(n-1)

r = f(3)

Gives the following display:

n = 3                   | n = 2   | n = 1   | n = 0
x = 0.33333333333333333 | x = 0.5 | x = 1.0 | ZeroDivisionError: float division by zero
                        |         |         | ZeroDivisionError: float division by zero ZeroDivisionError: float division by zero ZeroDivisionError: float division by zero

ZeroDivisionError: float division by zero

Incompatible with PyDev 2.7

File->New->PyDev Project->demo->Finish

Right click on demo project in PyDev Package Explorer,->New->File->demo.py
Type code "s='hello'",but the code is shown as "'olleh'=s"(that is to say when you type a letter such as 's',the cursor automatically jump to begin of 's' ) and no result display.

Tested with:

Win7 32bit+python 2.7.3+eclipse 3.7,3,8 and 4.0+pydev.org/updates

ubuntu 11.04+python 2.6.5+eclipse 3.7,3.8+pydev.org/updates

Pydev 2.5, 2.6 works well with live-py_2.0.0.201209171018.jar, but Pydev 2.7 has the above bug with live-py_2.0.0.201209171018.jar.

Note: this bug originally described a different problem with earlier versions of live-py.

Multiline statement breaks exception display

If I break a statement over multiple lines it messes up the exception reporting for some reason. Here's an example.

x = (
     '')
y = 2
z = 1/0

The division by zero isn't displayed. If I change the assignment to x into a single line, then the exception displays properly.

Yielding multiple values fails

Here's an example:

def foo():
    yield 1, 2

for x in foo():
    pass

It raises an error on the yield statement:

TypeError: not all arguments converted during string formatting

Yielding a single value works fine.

Spinoff live-py emacs mode into MELPA package?

Hi,

Thank you for writing this plugin and making it usable in emacs.

Would you be open to setting it up so that MELPA can pick it up?
I think I could help since I have some experience in setting up a MELPA package.

Don't run code until asked

Add a big Go button that starts running the code from a file. Each file has to be started, so you don't accidentally run something you didn't mean to.
Maybe an arrow button that expands the live code panel.
Playing with the splitter is not working well. Other ideas:

  • Add new buttons to the toolbar for go and stop.
  • activate live coding for each file independently
  • activate buttons only when in a Python editor
  • keyboard shortcuts

Other ideas that didn't get used:

  • change turtle view to live coding view with turtle and go button. Later add unit test dropdown.
  • Run as live coding... in the run menu
  • Add live coding to the context menu.

Incompatible with Python 3

Not surprising, but there are several errors if you try to run with a PyDev project that has selected the Python 3 interpreter. I think the user just sees a blank result.

Long output lines produce mistakes in the live coding window

When the output is very long, it seems some lines go missing.

Compare for example this screenshot, where the first 40 primes are calculated,
http://i.imgur.com/TbNIS.png
with the one in which the first 100 primes are calculated.
http://i.imgur.com/JHX5t.png

The first one is correct, but in the second one, some lines are blanked.

Here's the code I used:

from math import sqrt
def prime():
    yield 2
    yield 3
    ps = [3]
    c = 5
    while True:
        sqc = int(sqrt(c))
        for p in ps:
            if p > sqc:
                ps.append(c)
                yield c
                break
            r = c%p
            if r == 0:
                break
        c += 2

ps = prime()
for a in range(1,100):
    print ps.next()

Windows 7 Ultimate
Eclipse SDK 4.2.1
PyDev 2.7.1.2012100913
live-py 2.3.0.201211082133

Eclipse 3.8

I was able to get the plugin working in 3.8, by simply changing the eclipse version from 3.4 to 3.8 inside the jar file.

Code still runs when live coding display and live turtle view are closed

Sometimes I don't want the code to run, because it opens a window, tries to connect to a database, or something else that I don't want running all the time. I should be able to close the live coding display and live turtle view to stop it from running.

Here's some example code that opens the turtle window every time you type.

from turtle import Turtle
t = Turtle()

t.circle(100)

Printing multiline datastructures

I am using live-coding to view stuff like pandas dataframes.

df = pd.DataFrame(range(10), index=reversed(range(10)))

becomes df = 0 9 0 8 1 7 2 6 3 5 4 4 5 3 6 2 7 1 8 0 9.

Sometimes, I'd really like to see the datastructure like it would be printed, perhaps that could be done by sending some parts to a different buffer?

I dunno if using a comment symbol afterwards could denote datastructures that should be printed like they would be with print?

Like

df = pd.DataFrame(range(10), index=reversed(range(10))) 
dft = df.head(2) #=>

Sends the datastructure to a different buffer to be printed.

Another alternative would be to add a second mode, one that did not care about lines matching up, but just printed stuff over several lines.

No output when generators aren't "completed"

This is a bug that comes new with the fix from #12.

Testcode:

def foo():
    yield 1
    yield 2

f = foo()
x = f.next()

Expected output:

yield 1



x  = 1

Actual output
[nothing]

It works as expected when you use this code:

def foo():
    yield 1
    yield 2

f = foo()
x = f.next()
x = sum(f)

I suspect the problem is that either the report_builder or the code_tracer is keeping the generator alive, which means the program doesn't end, which means nothing is output? Not sure how you implemented the outputting at this moment.

Apart from this bug, and the one you found yourself, it's working pretty nice though :D

Incompatible with Python 3.3

As reported by Coaldust as part of #27, there are problems with the latest version of Python.

To be really specific, the problem seems to be the fact that "ast.TryExcept" has been renamed to "ast.Try" (and combined with TryFinally, hence the name) in Python 3.3. There may be other problems, but at least that is definitely a problem.

Add unit test example

I recently figured out how to run a unit test when live coding when the unit test is in the same file as the class under test. Here's an example.

import unittest

class Foo(object):
    def foo(self, x):
        if x >= 0:
            return x + 10
        return x + 5

class FooTest(unittest.TestCase):
    def testPositive(self):
        x = 3
        expected_result = 13
        f = Foo()

        result = f.foo(x)
        self.assertEqual(expected_result, result)

    def testNegative(self):
        x = -3
        expected_result = 2
        f = Foo()

        result = f.foo(x)
        self.assertEqual(expected_result, result)

if __name__ == '__main__':
    print Foo().foo(17)

elif __name__ == '__live_coding__':
    suite = unittest.TestSuite()
    suite.addTest(FooTest("testNegative"))
    test_results = unittest.TextTestRunner().run(suite)

    print test_results.errors
    print test_results.failures
  • Try to see if the same is possible when the test is in a separate file.
  • See if it can also work with submodules.
  • Add an example to the documentation.

Assign to tuple is broken

The following code breaks the display.

b, c = 3, 42

The error message is TypeError: Unknown target: <_ast.Tuple object at 0x...>.

Test with Python 3.4

As requested in issue #33, test whether live-py works with Python 3.4, because it was just recently released.

live-py is incompatible with Python 3.3.3

Upon upgrading from 3.3.2 to Python 3.3.3 (with nothing else changing) live-py stopped functioning correctly.

It still shows the values for global variables, and always reports syntax errors, but shows nothing for local variables.

Be aware that 3.4.0 is in beta. Since live-py seems to break whenever Python or PyDev updates, it might be a good idea to test it with 3.4.0 too.

for-loop with multiple variables errors in live coding

Code:

for a,b in [(1,2)]:
    print(a,b)

Expected output:

a = 1 b = 2
print (1, 2)

Actual output:

TypeError: Unknown target: <_ast.Tuple object at 0x021E87D0>

"normal" tuple assignment like this works fine though:

a,b = 1,2

The most recent bugfix works well for me :)
"Thanks again for all the bug reports. Let me know if I can return the favour on a project of yours."
Haha my pleasure. I'll keep it in mind!

Blank lines mess up scroll

Blank lines or comments at the end of a Python file mess up the live coding display's scroll position, because it doesn't add any blank lines to match them. It should just ensure that the display has the same number of lines as the document.

Scrolling doesn't move line numbers

Steps to reproduce:

  1. Open a Python file.
  2. Turn on live coding.
  3. Type more than one screen of valid Python so the scroll bars are active.
  4. Scroll the live coding display up and down using the scroll bar to its right.

Expected behaviour: everything should scroll up and down together - the live coding display, the source code, and the line numbers.

Actual behaviour: the line numbers do not move until you click in the source code.

May be able to just mark the ruler with the line numbers as invalid so that it repaints when we set the scroll position of the editor from the scroll event of the live coding display.

Freezes in infinite loop

Usually, an infinite loop will stop because the message limit is reached. Sometimes, this doesn't work:

def foo():
    while True:
        pass

foo()

Strangely, a very similar loop does stop because of the message limit.

while True:
    pass

Maybe the simplest fix is to use a timer instead of a message limit. That would solve some problems I've had with complicated turtle graphics code hitting the message limit.

First line of display is not shown

Even if something happens on the first line of the code that should be displayed, the first line of the display is always blank.

For example:

s = 'Hello'
s += ', World!'

First line of display is blank, and the rest is this:

s = 'Hello, World!'

PdfTurtle doesn't support fill

Here's an example that works in Eclipse, but not with PdfTurtle.

def draw_spiral(t):
    t.fillcolor('blue')
    t.begin_fill()
    for i in range(20):
        d = 50 + i*i*1.5
        t.pencolor(0, 0.05*i, 0)
        t.width(i)
        t.forward(d)
        t.right(144)
    t.end_fill()

if __name__ == '__live_coding__':
    global __live_turtle__
    draw_spiral(__live_turtle__)

elif __name__ == '__main__':
    from Tkinter import mainloop
    from turtle import Turtle

    draw_spiral(Turtle())
    mainloop()

Incompatible with PyDev 2.7.5.

Environment:
Windows XP 32-bit
JRE SE 7 U21 10.21.2.11
Python 3.3.2 (that's CPython, not Iron Python, Jython, or a more exotic implementation)
Eclipse Classic 4.2.2
PyDev 2.7.5.2013052819
live-py 2.5.0.201304211713

Error:
Live evaluation window does not appear. The menu entry itself /does/ appear, and responds to being checked/unchecked.

Message from Error Log:
"Plug-in live-py was unable to load class live_py.PyEditDecorator."

Eclipse and PyDev itself appear to be functional (e.g. Python code completion works, as does live syntax checking, and executing valid code and viewing the output in the console).

This occurs reliably.

Downgrading the version of live-py to the previous version, and upgrading PyDev to the nightly version, did not change anything.

Knowledge of any workarounds would be appreciated. I may have installed something wrong, but I followed the instructions as best I could.

I attempted to report this bug before on the blog, but my posting was deleted for some reason. Since I had already deleted the installation of everything, I had to re-install just to get the information to resubmit the bug report here, once I found out how. I hope it won't be ignored or destroyed a second time.

Activate turtle view separately for each file

Version 2.8 made sure that you had to launch live coding separately for each file, but having the turtle view open will still run any open file.

Add a big Go button to the turtle view, and make it work the same as the Start / Stop Live Coding buttons.

Display exception objects

When you name the exception object in an except block, we should treat it like an assignment. For example:

try:
    raise RuntimeError('Bad stuff happened.')
except Exception as e:
    f = e

This code should have the following display:

e = RuntimeError('Bad stuff happened.',) 
f = RuntimeError('Bad stuff happened.',)

Can't copy text from live coding window

I can't copy text from the live coding window. I can select it, but ctrl+c doesn't work, and I can't right-click it to select "copy" anywhere either.

Windows 7 Ultimate
Eclipse SDK 4.2.1
PyDev 2.7.1.2012100913
live-py 2.3.0.201211082133

Mystery assignment when chaining calls and multiple calls

This example shows a mystery assignment and multiple calls to the make_foo() method.

class Foo(object):   | 
    def foo(self):   | 
        return 3     | return 3 
                     | 
def make_foo():      |                                                       |                                                       | 
    return Foo()     | return <__live_coding__.Foo object at 0x7f2c8d65f510> | return <__live_coding__.Foo object at 0x7f2c8d65f550> | return <__live_coding__.Foo object at 0x7f2c8d65f5d0> 
                     | 
x = make_foo().foo() | <?> = <__live_coding__.Foo object at 0x7f2c8d65f5d0> x = 3 

Expected result:

class Foo(object):   | 
    def foo(self):   | 
        return 3     | return 3 
                     | 
def make_foo():      |                                                     
    return Foo()     | return <__live_coding__.Foo object at 0x7f2c8d65f510>
                     | 
x = make_foo().foo() | x = 3

.

Oops, hit the wrong button.

Exception not shown after multi-line statement

For example, here is an exception that doesn't get displayed:

quality = ''             # quality = ''
for c in ['a',           # c = 'a'       | c = None
          None]:         #               |
    quality += c         # quality = 'a' |

And here's what it looks like when the list is all on one line:

quality = ''             # quality = ''
for c in ['a', None]:    # c = 'a'       | c = None
                         #               |
    quality += c         # quality = 'a' | TypeError: cannot concatenate 'str' and 'NoneType' objects 

Extra panel empty when using Python 3.2

On Ubuntu 12.04, I have Oracle Java 7, Eclipse 3.7.2, Python 2.7 and Python 3.2 from the Ubuntu repository. I installed PyDev from within Eclipse, and added live-py-plugin to the dropins folder. I added both Python 2.7 and 3.2 as interpreters.

If I select Python 2.7 as the interpreter in my project, the live coding panel works as shown in the demo video.

With Python 3.2, the live coding panel appears but remains blank. There are no error messages (that I could find).

Live coding output doesn't print in proper column when coming out of recursion

When a recursive function is called and subsequently returns, it does not print in the 'earlier' colums. This is better explained in code:

Example code:

def recurse(height):
    if height == 0:
        return "yay"
    i = height
    recurse(height-1)
    i = height

recurse(2)

Expected live coding output:

height = 2       | height = 1       | height = 0
                 |                  |
                 |                  | return 'yay'
i = 2            | i = 1            |
                 |                  |
i = 2            | i = 1            |

Actual live coding output:

height = 2       | height = 1       | height = 0
                 |                  |
                 |                  | return 'yay'
i = 2            | i = 1            |
                 |                  |
                 |                  | i = 1 i = 2

Don't display full list for list item assignment

In the following code:

L = ['a','long','list'] 
for i in range(len(L)):
    L[i] = L[i] + ' very' 

the full list is displayed in each column of the for loop, whereas displaying only the assigned item seems more appropriate.

Multiple lines from __repr__ method introduce gaps in display window

Emacs user here. This problem is easily seen with Numpy arrays:

import numpy as np
x = np.ones((3,3))



y = x + 1

I've left enough newlines between x and y definitions so that the display can print both while line-aligning them, but instead the display prints y two lines after it should:


x = array([[ 1.,  1.,  1.],
       [ 1.,  1.,  1.],
       [ 1.,  1.,  1.]]) 

### Note: y should start here! Not two lines below:

y = array([[ 2.,  2.,  2.],
       [ 2.,  2.,  2.],
       [ 2.,  2.,  2.]]) 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.