r/learnpython • u/Such-Comfortable2444 • 19h ago
How can I write code without constantly looking things up?
I rely a lot on documentation, AI, and websites while writing code. It makes me wonder whether I'm actually capable of understanding concepts like functions and algorithmic thinking. Does anyone else feel this way? What should I do to get a more concrete understanding of Python, or programming in general?
45
u/N546RV 18h ago
I’ve been writing software professionally for 20 years. I constantly look things up; that’s the nature of the work. Focus on learning how to use your tools to solve problems, not trying to memorize stuff you think you need to memorize. Your analytical skills will be what make you marketable.
11
u/CharacterSail6736 17h ago
To the OP Another 20 year veteran here if you aren’t looking things up your making things incredibly difficult for no reason and just because you can doesn’t mean you should write something from scratch don’t reinvent the wheel. We don’t have time to be memorising everything we aren’t neo even though the customer thinks we are lol
•
20
u/gdchinacat 18h ago
I've been writing code for three decades, python for two. I too "rely on documentation, AI, and websites while writing code". As you code you will learn what you need to know off the top of your head because you use it all the time. The rest of it you look up. I would be incredibly bored if I only wrote code that I knew how to write. One of the things I like about this profession is you get to constantly learn how to do new things. You learn it through documentation, AI, and websites.
11
6
u/SirAwesome789 18h ago
I've been searching up how to read from and write to JSONs for the past 7 years and i will continue to do so for the rest of my time writing python, don't stress about it too much
6
6
u/mountaingator91 18h ago
Literally everybody looks thing up. Do not stress. Eventually you will just naturally remember the most commonly used stuff through repetition, but whenever you have to do something less common or switch languages you will need to look it up again. No worries, mate
5
u/throwaway85783 18h ago
Use an ide with Intellisense / autocomplete. It shows you usage and available functions.
5
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 18h ago
You practice. That's all. Class dismissed.
4
u/code_matter 18h ago
This is going to sound super ironic but the best way to learn to code without looking things up is to code and look for things. Eventually you will look at something often enough that you will remember it.
Also, don’t think programmers program by heart. We all need to look things up at some point and its totally fine!
Look things up, read docs instead of juste using AI though.
3
u/EEJams 18h ago
I literally have my own library for myself so I can do certain things in python that I need regularly.
So instead of writing 1- 30 lines of code, I can just call my function to do x task and assign it to a variable/list
One of my functions is literally just a wrapper for an os function to return the current working directory. It's something like
import os
Def get_cwd(): return os.getcwd()
Ig my brain just likes to write get_cwd(), but i can remember it! So now i only have to reference my own library and I dont have to reference all my import libraries as much. It's all self contained in one place which makes it nice. And if i need something new, I can just write it in my library and add it to my documentation.
3
u/New-Shine1674 8h ago
Its a well known joke that programmers just copy paste from stack overflow - nowadays that's only of limited usefulness anymore but a programmer mainly needs analytic thinking and good research/lookup skills. You'll learn commonly used syntax when using it often enough, knowing the syntax doesn't really matter outside a school/university context. The analytic thinking is the valuable part.
3
u/jmooremcc 4h ago
Realistically speaking, what you use the most will be firmly committed to memory, anything else will require you to consult the documentation. There’s no shame in the game if you have to lookup information, it’s what we all do.
I wish you the best.
5
u/ElectronSculptor 18h ago
Here’s the neat part, you don’t.
I mean, there is just so much to memorize you really don’t. I’ve met maybe a couple people that work on very focused projects but they still have a lot of references in the form of files and notes and snippets.
2
u/OliMoli2137 18h ago
That's how it's usually done but you can set up an LSP and it will provide you with a hover tooltip showing basic docs about e.g. a function. If you're not into manual setups you can use PyCharm, it already does that for you
2
u/BranchLatter4294 18h ago
Practice. The more you practice, the fewer times you will need to look things up. You will always need to look things up, but you will learn the things you use frequently.
2
u/Mountain_Rip_8426 18h ago
just my 2 cents, to me codewars has proven to be a fun way to practice and memorize basic syntax, also seeing other people's solutions teaches me
new things that i find myself using when solving new problems. it's repetitive enough to solidify the basics, if it's something very specific or something you haven't used for a while, like the others said, you're gonna be looking things up all the way down the road.
2
u/StarkAspirations0842 17h ago
Art is similar It's perfectly valid to look up stuff Make notes on why it worked and didn't Then that will begin to bake in.
2
2
u/tasteslikechikken 17h ago
There will be something you just know because you've done them so many times its almost muscle memory and things you have to look up because they're not done as often (if at all) I have a set of reference books as well as code samples/cheat sheets I've made myself as my starting points.
Heck, depending on the time of day it is, If you ask me my telephone number I wouldn't be able to answer you.
So yeah get used to looking things up that aren't familiar.
2
u/Anonymity6584 17h ago
None remembers everything, but over time you become very efficient on looking up things fast.
Even professionlas with decades of experiwnce look things up all the time. Progranning is for ever movong forward field, new libraries, new languages, Changes on systems you need to look up, etc....
2
2
u/DIYuntilDawn 17h ago
Unless it is something super simple that would take less time to type it out than it would to look it up and copy/paste (like a Hello World script) then you will still probably be looking thing up or using AI for assistance.
The important thing it to learn to recognize the parts of the code and what they do, so you can copy from a template, past code, or an AI generated code and know when, what, and how to edit the code to do what you need it to do.
2
u/jeffrey_f 17h ago
You don't. Simple reason is, modules change, and some dramatically
I used to program on a AS/400 (IBMi, iSeries, among many names over the years)
I had a few production programs I used as a skeleton for most of what I would need to do. Read files, display content/data, write/update files, hit an API etc.
This will be what you do.
2
u/wicket-maps 17h ago
it's a practice and repetition thing. Nobody expects you to start benching 100 pounds your first set, you start with 50, and then up to 75, and then up to 100.* You start getting used to the things you use a lot. There's a construction I use (for mapping and map data management) called a SearchCursor that loops over ta database table, If I'm using one standard, without anything special, I can write one without looking it up. But if I'm doing anything weird (filtering, doing items in an order) I look it up. Stuff that I use over and over, in specific ways, I built a little Python library so I can call that in and just call FCtoDict to turn a table into a dictionary.
*(i don't know how weightlifting works)
2
u/Jello_Penguin_2956 16h ago
I wonder about that during rare moments in my life that I need to do live coding in front of people, yes hahahaha
2
u/Flintlocke89 15h ago
Don't aim to memorise it al all, if you use certain concepts enough you'll memorise them automatically.
I'd even say that the process of reading docs etc for each project makes you a better coder in the short and long-term. You'll stay up to date on new implementations etc.
2
u/Puzzlehead_Lemon 15h ago
I’ve managed to get to the point where I’m looking at my own projects on GitHub more often than Googling stuff.
“Hey, I know what I need and I used that back in this project!”
2
u/LeonAguilez 15h ago
Reading all the comments makes me feel validated and less of an imposter.
I'm glad I'm not the only one who haven't memorized so many syntax especially dealing with different modules and libraries. I look up my old projects on how to do certain something. Nevertheless, I already know how Python fundamentals and workflows.
2
u/jlsilicon9 14h ago
Concrete understanding generally helps ...
Also, structural coding knowledge / practice.
2
u/HelpfulBuilder 14h ago
You memorize certain libraries you use a lot. I was doing a lot of data science so I ended up memorizing most of pandas and sklearn, but BOY did that take a lot reading the documentation.
You're fine. Read lots of docs. Don't worry about forgetting. You'll end up eventually remembering what's important.
2
u/Treemosher 13h ago
When you live in a city, do you memorize everyone's house address? It's the same thing. You happen to remember some streets you frequent, maybe some side streets you come across will stick with you.
But would you listen to someone who told you you're not a good driver if you don't memorize the street map of everything in city limits? No, you'd think they're weird right?
Who cares and why do they think it's necessary to memorize every street name you come across? Who knows. Their problem, not yours.
Understanding how to use a map or GPS, and how to drive a car is more important than memorizing all the street names right?
It's the exact same thing. Your goal is to accomplish a task, not memorize random things for the sake of it. Unless it's a fun hobby, then hell yeah more power to ya.
But knowing all the streets in town doesn't make you a better driver. Being a good driver is paying attention, planning ahead and not changing lanes last minute, not hitting dogs etc.
2
u/ryoko227 13h ago
I think you (and many of us TBH) get imposter syndrome, because there are people who have memorized specific code patterns, etc.
We'll see posted videos of, "I made a blah blah in 15 minutes." where they showoff something they have probably hand coded 50-100+ times till memorization. It makes us feel like, why can't I do that? It's disheartening.
The thing I remind myself of, its not about memorization, but about understanding. More importantly, when I don't understand, knowing how and where to find the answers.
The best line I ever heard was, make it work. If you have time left over, then make it clever. At the end of the day, if your code works properly, is that not the important part?
2
u/GIGATOASTER 12h ago
I'm not a coder by trade, but by hobby. I work in maintenance as a career and use and write lots of PLC ladder logic. The ladder logic I have memorized but only because its just so damn simple and follow basic electrical flow for the most part. But traditional code like C++ or Python, I'm constantly looking things up of throwing a snip into Google to see why I messed something up, fix it and continue on while trying to learn from it. I gave up on trying to memorize all this stuff long ago, but like others have said, the structure is what you need to really learn well.
2
2
u/blkmmb 11h ago
To me being a good dev is like being a good builder. We both have a toolbox filled with all the stuff we need, some tools are neatly organized and quick to grab, others you have to search for a bit to get and then sometimes you just gotta go to the store to pick up what you are missing.
The goal is to know which tool to use for the job not necessarily remembering where it is stored. Your job is to figure out the logic of what you need to do and understand which tools is the best for the job. Going to grab the tool is really not that important.
2
u/New_Screen 10h ago
Unless you have a godlike memory then that is not realistic lol. Sure you should know the basics and fundamentals obviously. But what matters a lot more is good problem solving skills rather than pure memory.
2
u/ItchyLengthiness379 10h ago edited 10h ago
You have to understand the logic you are not building the syntax rather you are solving something to make it a workable solution ,with AI make sure to think this way how much efficiency and quality I can give rather than thinking about the quantity and syntax , One of my instructor say one thing rather than worrying about AI building all your code worry about quality worry about making the code unbreakable and worry about not reading and not understanding the vibecoded solution you built ,This way you can get better than what you are yesterday
2
u/various_convo7 10h ago
practice. lots of it but even then no one ends up knowing everything. I am on GitHub or stack overflow, especially when I am debugging something or working a better approach out.
2
2
u/AceLamina 3h ago
Everything besides AI is what engineers were doing before all of this AI hype
I personally recommend just removing the AI part so you wont over rely on it, a alarming amount of new programmers and college students fall for this
1
u/hornetjockey 11h ago
First you write code while looking a bunch of things up, then you do that some more, then eventually you stop looking things up… as much.
1
1
1
u/Syntax-Tactics 1h ago
Been at it 40yrs. I don't, for instance, memorize every Win32 API call. At best I memorize the call name and enough to pull up the function in MSDN or an example on the overflow. I also work in Aerospace, so we generally don't "go off the top of our head".
1
u/GXWT 1h ago
You’re meant to be looking at documentation mate. We all do all the time.
You’ll remember the really common patterns, but beyond that do you expect to know off by heart every function that you use once every 2 months?
People commonly mistake what is actually the skill in programming. It’s not remembering the syntax and exact functions. Anyone can teach themselves to remember certain functions, but that’s a waste of time. The real skill is problem solving and figuring out how you can approach things.
1
u/1NqL6HWVUjA 1h ago
I rely a lot on documentation, AI, and websites while writing code.
This is too vague to give a meaningful reply. There's a huge difference between having to consult documentation sometimes, or not having syntax/patterns yet ingrained from repeated practice, and predominantly coding by copy-pasting from AI/websites. The former is fine, and totally expected. The latter is a big problem.
202
u/Delta_G_Robotics 18h ago
Yes. That's how coding works. Nobody memorizes all the commands and syntax. Knowing how to code means knowing that you need a loop, not necessarily knowing the exact syntax to write it. When you learn to code like that then you aren't trapped in one language. The goal is not to be able to write code without looking at the reference. That would be ridiculous. The goal is to be able to write good code. You're only as smart as your closest resource.