[PYTHON] Use edump instead of var_dump for easy debugging & efficient data content (PHP)

In PHP etc., it is easy and quick to debug by displaying the value by a method called Print debug.

sample.php


$val = "value";
print $val;

Or you can use var_dump. This is mainly used to check the contents of the array.

sample.php


$arr              = array();
$arr["greetings"] = "Hello world!";
$arr["T or F"]    = true;
$arr["check_val"] = null;
$arr["empty"]     = "";
$arr["number"]    = 100;

$arr2             = array();
$arr2[0]          = "I am an array.";
$arr2[1]          = "You can put various types of data.";
$arr["array"]     = $arr2;

var_dump($arr);

The value display result with var_dump is as follows. capture-1.jpg

Although print and var_dump are very easy and easy, there are problems such as page collapse in Web development. On the other hand, there is also a method of using full-scale xdebug, but there are many problems such as it cannot be used depending on the server environment, and it takes time and effort because it has to be installed.

** Therefore, use edump, which is more sophisticated than var_dump and does not require time-consuming preparation such as full-scale debugging software. You don't need to install anything on the server. ** ** You can check the value visually as shown below.

sample.php


$arr              = array();
$arr["greetings"] = "Hello world!";
$arr["T or F"]    = true;
$arr["check_val"] = null;
$arr["empty"]     = "";
$arr["number"]    = 100;

$arr2             = array();
$arr2[0]          = "I am an array.";
$arr2[1]          = "You can put various types of data.";
$arr["array"]     = $arr2;

//Example of executing the edump function
_v($arr); 

After execution, the result will be displayed in the browser like this.

capture-2.jpg

With edump, the value being debugged is displayed in a separate viewer window instead of the main website window. Also, unlike var_dump, the display is neatly formatted and the contents can be grasped quickly. In addition, Google Chrome and FireFox provide plugins that add the function of edump to the developer tools, and after installation, you can check the website display and debug values at the same time in one window. capture-3.jpg

** The key to efficient programming is efficient debugging. Efficient debugging work is "efficient grasping the situation inside the program." In order to quickly grasp the internal situation, visuality leads to the final efficiency improvement. ** **

With edump, you can use the easy and efficient debugging function of var_dump. However, since it is a simple debugger, you cannot use full-scale functions such as xdebug that pause the program in the middle.

■ Simple debugger: edump http://www.edump.net/

■ Tutorial http://www.edump.net/res/GettingStartedWithEdump_ja.pdf

Recommended Posts

Use edump instead of var_dump for easy debugging & efficient data content (PHP)
Use urlparse.urljoin instead of os.path.join for Python URL joins
PyPI package for super easy use of Cotoha on Google colab
It is convenient to use Icecream instead of print when debugging.