"So you are learning Python"

ยท 653 words ยท 4 minute read

Okay. So you are learning Python.

You know it’s good for non-tech people to learn because of its simple syntax and popularity.

You might have found courses on YouTube or other websites, some giving you interactive panels, or some exercises.

But you just don’t feel like doing it anymore when it comes to classes or things that doesn’t sound daily-life to you.

I get it. And guess what: it’s okay not to understand those things in this stage anyway.

“What stage?” you may ask.

You see. I learned the language when I was a senior-high. I didn’t understand classes or object-oriented programming or stuff like that. But I did keep going and now I am a master student whose daily life is programming in Python. (Of course I don’t program as well as people in CS, but I solve problems in it.)

Looking back, I found myself being through 4 stages:

  • Stage I: Got the basic
  • Stage II: Actually used it
  • Stage III: Learned about refactor and unit testing
  • Stage IV: Be part of the community (<- I am here)

Let me explain them one by one:

Stage I: Got the basic ๐Ÿ”—

I learned the language as a senior high school student on Codecademy.

The interactive panel, good. The verbose instruction on how to proceed, good. Though the practices appeared mundane, keep in mind that in this stage, repetition is the key.

As I said, things about Object-Oriented Programming (OOP) was rather confusing at this stage. But I just did the exercises (which were mainly repititon anyway) and proceeded.

Stage II: Actually used it ๐Ÿ”—

After Stage I, I tried to use the language whenever I found possible.

Doing the calculation with python3 interactive shell on the terminal? Done. Writing functions to display theoratical prediction, done.

But the main part is to process the data collected in lab courses (even though sometimes it’d be easier done in Excel).

I became friends with matplotlib, scipy and numpy in this stage. And I believe you will too.

Stage III: Learned about refactor and unit testing ๐Ÿ”—

After writing those scripts for a long period of time, I found the clumsyness of those scripts anonying. Functions that call each other and led to un-debuggable disasters? print(...)s inbetween as log messages? All these burdens led to an inevitable lesson: refactor and unit testing.

I replaced codes by snippets on Stack Overflow, wrote one-liner whenever possible and non-misleading, and I tested functions that would last for a while with unit testing.

I understood OOP at this point, since sometimes you do need to store data into things that can act on other things. (And no that won’t make you understand OOP without going through the previous stages.)

Stage IV: Be part of the community ๐Ÿ”—

Now, I write functions and classes intuitively (though it’s never easy). I collect modules and pack them into a package. (I learned Git and GitHub in Stage II&III so it’s easy to develop them in a well-organized way.)

I developed a package called b2pandas that helps me deal with the analysis code that I used for my Master research.

I won’t say I am over this Stage until I upload the package on PyPl1. In such way, one can say he/she is a part of the Python community and be confident on making this whole environment a better place.

Summary ๐Ÿ”—

If you still want to learn Python, here are some points that you may keep in mind when having this journey:

  1. It’s okay not to understand some concepts – use them as if you knew it and someday you will.
  2. Use the language whenever you find possible, even if it costs a bit more time.
  3. Learn about refactor and unit testing when you find your codes hard to read.

  1. PyPl is like App Store for Python packages, but every package is free and open-source, which means you can contribute and use them almost all you want. ↩︎