Debugging a scripting language like ruby

2024/4/15 1:12:47

I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.

I am wondering how to do debugging. At present the steps I follow is,

  • I complete a large script,
  • Comment everything but the portion I want to check
  • Execute the script

Though it works, I am not able to debug like how I would do in, say, a VC++ environment or something like that.

My question is, is there any better way of debugging?

Note: I guess it may be a repeated question, if so, please point me to the answer.


Your sequence seems entirely backwards to me. Here's how I do it:

  1. I write a test for the functionality I want.
  2. I start writing the script, executing bits and verifying test results.
  3. I review what I'd done to document and publish.

Specifically, I execute before I complete. It's way too late by then.

There are debuggers, of course, but with good tests and good design, I've almost never needed one.

Related Q&A

Running unittest Test Cases and Robot Framework Test Cases Together

Our group is evaluating Robot Test Framework for our QA group, not just for BDD, but also to possibly cover a lot of our regular functionality testing needs. It certainly is a compelling project.To wha…

numpy.ndarray enumeration over a proper subset of the dimensions?

(In this post, let np be shorthand for numpy.)Suppose a is a (n + k)‑dimensional np.ndarray object, for some integers n > 1 and k > 1. (IOW, n + k > 3 is the value of a.ndim). I w…

How can I work with a GLib.Array in Python?

I am writing a plugin for Rhythmbox, wherein a signal raised is passing in an object of type GArray. The documentation for GLib Arrays shows me a few methods I am interested in, but am unable to acces…

Categorical dtype changes after using melt

In answering this question, I found that after using melt on a pandas dataframe, a column that was previously an ordered Categorical dtype becomes an object. Is this intended behaviour?Note: not looki…

python apscheduler not consistent

Im running a scheduler using python apscheduler inside framework. The function runserver is supposed to run everyday at 9 a.m but it is inconsistent. It runs most days but skips a day once in a …

Change timezone info for multiple datetime columns in pandas

Is there a easy way of converting all timestamp columns in a dataframe to local/any timezone? Not by doing it column by column?

Change permissions via ftp in python

Im using python with ftplib to upload images to a folder on my raspberryPi located in /var/www. Everything is working fine except that uploaded files have 600 permissions and I need 644 for them.Which …

Creating a Persistent Data Object In Django

I have a Python-based maximum entropy classifier. Its large, stored as a Pickle, and takes about a minute to unserialize. Its also not thread safe. However, it runs fast and can classify a sample (a si…

How to catch specific exceptions on sqlalchemy?

I want to catch specific exceptions like UniqueViolation on sqlalchemy.But sqlalchemy throw exceptions only through IntegrityError.So I catched specific exceptions with below code.except sqlalchemy.exc…

numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares on first run only

I have been wrestling with a known and documented SVD converge issue. Having read up on similar issues raised by others, I have double checked my data and reduced this to a tiny DataFrame - 10 rows/2 c…