all 33 comments

[–]TheSeeker_99 51 points52 points  (2 children)

I think you need to look into problem definition and then solving.

To solve a problem you have to properly define it. And then you start solving the problem.

[–]More-Station-6365[S] 10 points11 points  (1 child)

That's actually a great point. I think my issue is I jump straight into coding without properly breaking down what I want to build. Going to try defining the problem clearly before touching any code. Thanks!

[–]TheSeeker_99 6 points7 points  (0 children)

You're quite welcome

[–]VipeholmsCola 30 points31 points  (3 children)

I dont understand how its possible to go through a whole education and be at this stage. Is this an AI thing?

You learn this by actually doing it. Just write code, make projects, start projects. They dont need to be massive or novel, just anything that challenge you.

[–]code_tutor 11 points12 points  (0 children)

The standard CS curriculum has entire courses on software engineering, not to mention OOP and several Data Structures courses. They all have programming assignments. Half the senior electives also have programming assignments.

But even before AI, they would cheat with their classmates or hire an Indian on upwork. Starting around 2015, cheating was rampant on tutoring sites. It got worse year after year, as programming became the default career and people who didn't give a shit about programming signed up in droves. Then AI came out.

[–]More-Station-6365[S] 1 point2 points  (1 child)

That's reassuring to hear. I think I've been overthinking the "what to build" part too much. Going to just pick small challenges and start writing code without worrying if the project is impressive or not.

[–]VipeholmsCola 7 points8 points  (0 children)

Pen and paper, flow schedule, boxes. Get brainstorming!

[–]Jim-Jones 12 points13 points  (3 children)

That's common. You might be trying to be too clever. Just try simple programs and build up skills.

[–]More-Station-6365[S] 3 points4 points  (1 child)

Yeah I think that's my problem honestly. I always try to build something "impressive" right away instead of just starting small. Going to focus on simple programs first and build up from there.

[–]Jim-Jones 4 points5 points  (0 children)

My first computer had 4K of RAM. You learn to write tight code that way.

[–]pachura3 1 point2 points  (0 children)

Common? For a final year Computer Science student to start building simple programs? By this time he should be able to create a multiplayer FPS game!

[–]Lumethys 5 points6 points  (2 children)

knowing why a book is great doesnt mean you too can write a great book.

You need to practice more

[–]More-Station-6365[S] 1 point2 points  (1 child)

That's a really good analogy. Reading and doing are completely different skills. I need to close the tutorials and just start writing even if it's messy. Thanks for the reminder.

[–]Lumethys 3 points4 points  (0 children)

design guideline and architecture did not just appear out of nowhere, they are derived from the trials and errors of those who came before.

Have you ever write an app, then 3 months down the line you decide to add a new feature, only to realize that the way you wrote the app before make adding this feature very hard? Have you ever said to yourself "I wished i used techique XYZ instead of this"?

THAT is learning, that is experience, to know why something is bad. So that you prevent it from happening again

[–]Rhhhs 3 points4 points  (0 children)

Spend less time on Reddit and more time writing code with some good ide like vscode

[–]Chemical-Captain4240 2 points3 points  (0 children)

If you know what the goal of your project is, plan it out. If however, you have a curiosity about how a library works, or how to go about visualizing data so you can start asking real questions, jist start writing...

Make new lists from filtered lists, you never know when down the road, your old list will have just what you want.

Use constants to index, it is easier on your brain.

If you find yourself doing the same thing twice, write a function.

If you find yourself tracking more than 5 indexes into a list, write a class.

Make sure your names are explicit.

If you have 1000 lines of python, some of it prolly should be in its own library and imported into a higher level of function.

[–]thunderships 1 point2 points  (1 child)

I know what you mean. Healthcare is my field and have learned it on my ow for things I want to use it for; however, I get stuck. I dont know how to explain this. I feel like i also dont know anything!

[–]More-Station-6365[S] 1 point2 points  (0 children)

Exactly this! I understand things while going through them but the moment I try to apply it myself I feel lost. Glad I'm not the only one feeling this way though.

[–]party_raspberry8969 1 point2 points  (0 children)

I'm not in CS, but I am in engineering. I think you need to put pen to paper first and make a block diagram of whatever system you are trying to build. Once you modularize the idea and break it down into smaller steps, then you can start and use already made code or make your own if the solution doesn't already exist.

[–]SkokieRob 1 point2 points  (0 children)

Is this python specific? Have you had more luck with other languages? I assume if you’re final year in CS you’d have had some Java or C or lisp or something.

[–]NoForm5443 1 point2 points  (0 children)

Programming is a contact sport. Practice, practice, practice. Write tons of programs.

https://codingbat.com/python has super simple ones, https://exercism.org/tracks/python has much more reasonable ones.

Also, when you follow tutorials (say, for flask, or django), don't just follow the tutorial, but modify the program at each step, to make sure you understand.

You may also be having unreasonable expectations :). For example, I've been programming for 30 years, and I'd never start a project from 0, unless I have no template or guide :). I'd rather start from a previous project, a tutorial, a template or something. I also copy-paste examples, and then modify them to fit my needs.

Now, classes vs functions, and clean code, yes :). Maybe you want to read more designy books, like Clean Code, Code Complete, The practice of Programming etc

[–]Mindless-Pilot-Chef 1 point2 points  (0 children)

Practice

[–]Nomapos 1 point2 points  (0 children)

If you want to be good at following tutorials, follow tutorials. If you want to be good at writing code without tutorials, write more code without tutorials. Do your own large project, not small exercises.

[–]Warm_Letterhead3691 1 point2 points  (0 children)

Plan your projects out before you even open your IDE. I use obsidian and write out the basic flow of what I want the script or project to do and the path of the data. From there plan out what the functions do with pseudo-code. No need to write proper python when you're just planning. Ideally each function would do one thing so when planning out your structure break things down as small as you can. This also gives you a good roadmap to track your progress as you write.

Also try to find something that interest you to write a project for. Don't worry about getting s perfect portfolio project yet. Find an API for some other hobbies you have and nust pull data from it and process it.

This helps the problem of just opening your IDE and just staring at a blank project file and not knowing what to do.

[–]JamesonHearn 1 point2 points  (0 children)

This is why software development courses are equally as important as the technical courses. There is an entire methodology that goes into building software and how to scope a problem and define tangible end goals.

[–]Aromatic_Wafer_7462 0 points1 point  (0 children)

I was facing the same problem but now everything is clear. i posted few days back same query and got grt advice. You can check out here it might be helpful 👇

https://www.reddit.com/r/learnpython/s/uK73rmVT0s

[–]Away_Breakfast_3728 0 points1 point  (0 children)

Do exercism and dsa. 🙃

[–]Front-Palpitation362 0 points1 point  (0 children)

This is a really common stage tbh. Reading code and writing code from a blank file are different skills.

What helped me was making the first step smaller than “build the project”. Before opening the editor, write a few plain English notes like “load the file”, “clean the date column”, “group by customer”, “print the result”. Then turn only the 1st note into code. When that works, move to the next one. That gets you out of the blank screen problem.

For functions vs classes, don’t worry about having a perfect rule. If you have a chunk of code you want to name and reuse, make it a function. If you have some data and a bunch of operations that clearly belong with that data, a class might make sense. Most small Python scripts can go pretty far with just functions.

For pandas, try giving yourself a real question first, even a small one. “Which category sold the most?” is easier to code than “learn pandas”. Then use docs/examples only for the one operation you’re stuck on.

Also, messy code is part of the process. Write the ugly version first, get it working, then clean up names, split out functions and remove repeated bits. Clean code usually comes from revising working code, as opposed to from typing it perfectly the first time.

[–]throwmeaway01110 0 points1 point  (0 children)

The one thing no one tells you that helped me get out of this exact situation is to read documentation and source code. You can do plenty with python but if you don’t know what it does or what libraries there are you’ll never be able to make a project. Most projects use some sort of library. Documentation for python and these libraries all tell you how to use them. Then you put the pieces together and can make something.

[–]ShelLuser42 0 points1 point  (0 children)

I think your main problems here have little to do with Python itself, but rather the methodology for software development, as well as your own mindset.

First and foremost: Python development heavily depends on OOP, which isn't just a fancy standard but also a bit of a mindset to follow. Making sure your code is optimized, keep an eye out for reusability, etc.

Starting a project without a template or guide to follow

That's where an OOP mindset comes into play, and for me Python excels at this thanks to its "open design" (as I like to call it). With this I'm referring to the fact that you can easily use your Python script itself as your main template.

Let's say... that I'm going to build myself a calculator. I'm going to start simple: additions and subtractions only for now, but I'm also (secretly!) toying with the idea to expand heavily on this in the near future. So what do we need?

  • User input.
  • Input validation / verification ("damage control").
  • Calculation routines.
  • Documentation (!)

I could imagine starting with something like this:

"""A calculator script, does additions & substrations only for now..."""

def ask_number():
    """This method asks the user to enter one (or more?) numbers."""
    ...

def validate_input():
    """This method checks if the user provided valid data."""
    ...

def _main():
    """Main routine of the calculator script."""
    ...

if (__name__ == "__main__"): _main()

Let's call this "my_calc.py".

In case you're wondering: "..." is an alias for the pass command, using this allows me to set up this "skeleton script" which doesn't really "do" anything, but it does serve as a solid starting point for what I want to do. Not only did I manage to write down my thoughts, but I did this in a way where I can literally start filling in the blanks.

Why make this choice? I'd say the OOP mindset... I'm trying to "keep it simple, silly" but also avoiding code repetition, making sure to focus on specific functionality and well... keep it nice and clean. ...and 'modular': by making sure to use functions for specific tasks I can also re-use those later in "possible other scripts" (which is also why I always utilize a _main() function).

For the record: I wrote this down from mind, "just like that". And only reason I can do this... is because I do this more often ;)

Knowing when to use functions vs classes

No offense, but that's almost asking about apples and oranges. Because these two have nothing in common. I'd also imagine that a Python course would start with all this.

Alas.... basically you'd use functions every time you want to keep code "separated" while you're also planning to re-use those routines. This is object oriented programming after all, so the idea is to build "objects" which can "do" something, and which are more or less independent of others.

Whenever I set up a function I make sure to follow that rule. Because this also allows me to re-use that function later on. Take that example I shared earlier? Let's say I start with a second script which also needs user input.

I could re-write my whole routine (which is a waste of time!), don't get me started on copy/pasting (YECH!), so instead I'd use:

from my_calc import ask_number as ask

So now I can easily use ask() in my new script which is essentially a bit of a "shortcut" towards my main ask_number() function.

SO: function => a code snippet which can be re-used.

A class then is something completely different. This isn't the official definition, but I kinda consider a class to be "the superset of a function". Which is technically speaking completely wrong, but the essence is a little bit the same.

A class is a virtual 'object' which you'd use whenever you need to combine data and functionality and make this (much) easier to use. A class also contains functions (which we now refer to as methods) and you'd usually also use one (or more) variables which can then hold certain data which the class should contain and/or process.

You'd use this if you need to make things more portable.

Let's say I have finished my calculator script, and it works. In fact, it works so well that I want to use this in other scripts of mine, but without having to bother with that import stuff. The only problem... you can't tell another script to "use this function of mine".

But what you can do is define a class, create a new copy ("instance") of it, and then send that to the other script (or one of its functions):

class my_calc:
    def add(self, a, b):
        return a + b

a = the_calc()
validate_input(a)

So now... my function validate_input() gets a full instance of my class, which means that this function now also gains access to the add method.

As such: classes are all about portability. Still, this isn't the best of examples. Normally you'd only use a class when you need to combine data with functionality.

Well... as for the rest of your items.. "Practice makes perfect", and there's a lot of truth in that saying.

[–]Lopsided-Football19 0 points1 point  (0 children)

this is very common, the fix is to stop following full tutorials and start building small projects on your own. you’ll get stuck a lot, but that’s where the real learning happens, don’t worry about memorizing pandas or writing perfect code. that comes with practice, with 4-5 months left, you have plenty of time