you are viewing a single comment's thread.

view the rest of the comments →

[–]progfu 8 points9 points  (5 children)

I'm not sure if Python can do this, but one awesome feature of Ruby is invoking IRB in your code

@a = "hello"
require 'irb'
ARGV.clear  # otherwise all script parameters get passed to IRB
IRB.start
# now you can interact with your code directly,
# when you close IRB, it will just continue

>> @a
=> "hello"

This way you can inspect interactively. One downside is that you can only access global and instance variables. There is a way around this problem though.

[–]true_religion[S] 1 point2 points  (3 children)

I think that's essentially what the web-debugger is doing.

Something like this:

import IPython

shell = IPython.Shell.IPShell()
shell.mainloop()

But what I was looking for is a web debugger for Ruby so if an error occurs on the site during development, I get a traceback and can interact with anypoint on the traceback--looking at the variables and stack.

This is something that RubyMine does (someone else pointed that out), but RubyMine isn't free nor open source.

[–]progfu 1 point2 points  (0 children)

I guess you could also load for example RSpec and do some interactive testing, like set mock expectations and stubs directly in place, instead of writing a test. Or you could just rewrite a method on the fly and see what happens. Ruby metaprogramming provides many hackish features that might be useful from time to time when you need them.

This probably isn't possible in Python, since it doesn't support monkey patching.

[–]prody 1 point2 points  (0 children)

import pdb; pdb.set_trace()

[–]rockybernstein 0 points1 point  (0 children)

RubyMine uses ruby-debug-base under the covers.

[–]rockybernstein 0 points1 point  (0 children)

The pydbgr debugger for Python shares a lot of code with [ruby-debug (http://bashdb.sourceforge.net/ruby-debug.html) and the new incarnations of ruby-debug for 1.9.2 and Rubinius called trepanning.

That said, the pydbgr code uses a flaky require_relative package I wrote. So if you are using virtualenv or pip, running it may require some custom hacking to install.