DEV Community

Cover image for What is something that you recently learned that you wish you would have learned or understood earlier?
Waylon Walker
Waylon Walker

Posted on • Edited on • Originally published at waylonwalker.com

What is something that you recently learned that you wish you would have learned or understood earlier?

Cover Photo I call gaining clarity by David Travis on Unsplash


Mine is the python debugger. I was a long holdout thinking that print statements were sufficient. That was untill I started having errors crop up in functions that took minutes to run. The thing that I most notably wish I would have known about is post_mortem.

Example

[ins] In [4]: def repeater(msg, repeats=1): 
         ...:     "repeats messages {repeats} number of times" 
         ...:     print(f'{msg}\n' * repeats) 

[ins] In [5]: repeater('hi', 3)                                                                                                                                                                                                                       
hi
hi
hi

[ins] In [6]: repeater('hi', 'a')                                                                                                                                                                                                                     
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-0ec595774c81> in <module>
----> 1 repeater('hi', 'a')

<ipython-input-4-530890de75cd> in repeater(msg, repeats)
      1 def repeater(msg, repeats=1):
      2     "repeats messages {repeats} number of times"
----> 3     print(f'{msg}\n' * repeats)
      4 
Enter fullscreen mode Exit fullscreen mode

Debug with iPython/Jupyter

%debug
Enter fullscreen mode Exit fullscreen mode

Vanilla Debug

import pdb
import sys

pdb.post_mortem(sys.last_traceback)
Enter fullscreen mode Exit fullscreen mode

More

For more information about the debugger checkout the real python article. https://realpython.com/python-debugging-pdb/

Also keep a bookmark of the table of pdb commands from the article https://realpython.com/python-debugging-pdb/#essential-pdb-commands

Debug Session

debug session

Top comments (26)

Collapse
 
megazear7 profile image
megazear7

Docker.

  1. Install Docker
  2. Write a Dockerfile
  3. Have consistent, automated, development and production environments that can be easily distributed.
Collapse
 
nombrekeff profile image
Keff

Docker is amazing, although it has some little things that bugger me a bit, it's a really powerful and easy to use tool.

Collapse
 
aleksandrhovhannisyan profile image
Aleksandr Hovhannisyan

The only thing I know about Docker is that it's perfect for warming my cold hands in the winter months :) I've used it before with 0 knowledge of what sorcery is going on under the hood. I'll probably change that one day.

Collapse
 
waylonwalker profile image
Waylon Walker

I have recently started working with docker. Its quite amazing to work with. Your working environment can run almost anywhere!

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard • Edited

put whatever job title you want to become later on LinkedIn

job titles mean nothing, so you might as well use whatever is currently useful to your goals

contact me privately if you need to understand why and how to do it in your case

Collapse
 
waylonwalker profile image
Waylon Walker

Reminds be a bit of Ken Colemans philosophy of taking small intensional steps to get you from where you are to where you want to be.

Collapse
 
prahladmishra profile image
Prahlad Mishra

Unit testing and debugging, it's feels good to see when code coverage is >95%

Collapse
 
waylonwalker profile image
Waylon Walker

I love sitting down to work on a project with good coverage and passing tests!

Too many times I walk into an old project with no tests and it isn't working 😭

Collapse
 
prahladmishra profile image
Prahlad Mishra

Once in a while you get an opportunity to lead a project to start building an application from scratch. I feel lucky to be the one to guide, dictate and lead by example for my current one. Only thing is I need to make sure is timeline commitment to business is being met.

Thread Thread
 
waylonwalker profile image
Waylon Walker

Balancing tech debt is a real challenge.

Collapse
 
etampro profile image
Edward Tam

Nice! Realizing the value of debugger is a great step ahead.

This is not just a Python thing. It is coding in general. Being able to play around with the context within the runtime gives you so much more insight on how a language works.

This is pretty much the very first thing I try to figure out first when I start to learn a new language.

Collapse
 
waylonwalker profile image
Waylon Walker

I am heavy user of print statement debugging. Long running commands introduced me to the debugger, post_mortem definitely has hooked me in!

Collapse
 
kor3k profile image
kor3k

well, not "recently", but "all time" is for me vuejs. i used to use jquery before, and vue completely changed the way i think in javascript. it's virtual DOM, encapsulation and modularity was a total banger.
also tought me a lot of new information about the DOM and it's rendering in browsers.

and when i recall how did i struggle some times to achieve something with jquery's spaghetti api, while with vuejs the same thing is easy as pie, i wish i learned it earlier.

Collapse
 
waylonwalker profile image
Waylon Walker

I had a similar experience with react

Collapse
 
nombrekeff profile image
Keff

Flutter/Dart, It's really nicely done (really good apps come out), I hoped to have learned it before Ionic : )

Collapse
 
waylonwalker profile image
Waylon Walker

Flutter seems fascinating!

Collapse
 
nombrekeff profile image
Keff

Yup, it's pretty cool! Worth giving it a shot.

Collapse
 
koresar profile image
Vasyl Boroviak

Stupid simple code is better than smart elegant one.

Collapse
 
waylonwalker profile image
Waylon Walker

The ability to understand and explain goes a long ways!

Collapse
 
waylonwalker profile image
Waylon Walker

I bet that helps alot. I always find it amazing how much you learn about high level things by digging in underneath them.

Collapse
 
nombrekeff profile image
Keff

Totally agree, knowing how a system works gives you a big advantage over those who don't (in some senses)

Collapse
 
owsilva profile image
Walace Silva

I would like learned writing React code better. Today I have improved it

Collapse
 
waylonwalker profile image
Waylon Walker

I 💕 react. State management is amazing, and tools like gatsby, next, or create react app, make getting started so easy!

Collapse
 
stojakovic99 profile image
Nikola Stojaković

Setting up and securing a server. Pretty basic stuff for server admins but something I never had to do until I have built my personal site.

Collapse
 
waylonwalker profile image
Waylon Walker

Personal sites are great for learning how to manage servers! We live in such a great era where you can get one so darn cheap, it's incredible. That is such a great skill to have.