r/learnpython 3d ago

Seeking help with building logic while learning Python programming

I'm a DevOps engineer with 2 years of experience, and I come from a commerce educational background.

I've tried learning Python several times in the past, mainly when I was switching jobs and preparing for interviews. However, I ended up joining companies where Python wasn't really required or where nobody was particularly concerned about my Python skills.

Currently, I use AI to generate scripts for many of my daily DevOps tasks. My biggest concern is that I'm not able to build the logic myself or write the syntax from scratch. I often struggle with knowing when to use what.

The last time I seriously learned Python, I got up to lambda functions. That was about a year ago, and now I've completely forgotten a lot of the basics, including data types and syntax.

I want to properly learn Python because it's one of the most commonly mentioned skills in the DevOps/SRE job descriptions I see, especially for bigger tech companies. I've also lost a few interviews in the past because of my lack of Python knowledge.:

I'd really appreciate advice from people who have been through a similar situation. What worked for you?

24 Upvotes

10 comments sorted by

View all comments

1

u/EEJams 2d ago

I can usually think of the logic required to make a script, but depending on what I'm doing it could take 15 minutes to a few hours to make it.

When i was in college doing engineering, i took a class where we wrote code to simulate a processor. You kind of build each hardware piece in code as an input/output module and "wire" then all together on a controller module in code.

So the way I like to program for work in python is similar. I wrote my own library for myself in python that basically has bricks of logic that I can then use in any script I build in the future. So I define my own python functions that I can pick and choose from at any time that handles a specific purpose. So like, I have code that will read an excel file into a datagram so I can then make a list of one of the columns or create a list of comma separated values that I can split into variables and do data analysis with. I have code snippets that will grab log files and rename them in the order I need to analyze them so I don't have to rearrange the files manually in excel. Things like that.

So i recommend starting your own library of functions you can pull from as needed and start with easy small tasks. I recommend using jupyter notebooks so you can break the code up into individualized sections and observe the output section by section.

Get VS Code or pycharm and try to get it all set up in one of those. Get a simple book of python and learn as much of the base language as possible. Python itself is quite simple and added complexity comes from third party libraries.

You can use AI to give you an example of functions to use to perform x task, but analyze the code and understand why it works. Don't ask for anything more than a few lines at a time, make sure you know how it works, and architect the code into working software.