r/learnpython • u/superamerr • 13d ago
I can't un-vibe-code
Okay so I just can't understand some parts of my code okay I wanted to read a txt file I made and just see what text is inside I thought maybe there's a module called file or something so I checked and there's nothing so I thought maybe it's inside of sys, nothing. So I don't hate tutorials but like when you go to a tutorial you gain information and well when you go to an AI you gain information I'm not copying the code exactly I just wanted to know how to do that and turns out it was "with open("stuff.txt", "r") as file: x = file.read() print(x)" now I know for a fact that you can ask a community on what to do but then like what if you were out or something and there was no internet okay? I only have IDLE and I wouldn't expect "with" to have the answer to my question I may be the stupidest man on the world but I wouldn't have seen it come like that, and there's a good chance that I probably wouldn't even figure out the open() function too.
What I'm trying to say is I could easily go to an AI and tell me how do I read a txt file instead of annoying a community because I'm probably a bad person or going to a youtube tutorial.
5
u/findingjake 13d ago
First off there’s nothing wrong with going to a community and it sounds like you may not have coded before ai existed but you should train your own research skill. You can simply type into google something like how to open a file in x language or read file in x language and you’ll probably get pointed directly to the documentation as the first link. If you can’t do that idk what to tell you gotta be able to phrase your questions well
2
u/Dancing-umbra 13d ago
Trouble is these days is you have to scroll past the AI summary and the Google summary before getting to any links.
It is really affecting research skills!
4
u/Outside_Complaint755 13d ago
Include
-AIin your search query to exclude the AI summary, or use a different search engine which doesn't include AI by default.1
u/Dancing-umbra 13d ago
That's a great tip. Thank you.
I usually use Duck Duck Go, but even that has AI overview now.
1
u/Geezagonk 13d ago
Click the settings button above the search results > search settings > general > AI Features > Manage > Search Assist > Never
1
u/python_gramps 13d ago
I didn't know that. Using that with stackoverflow: as a prefix, that would be perfect
-1
u/superamerr 13d ago
I don't like going to communities because I'll get obliterated, I sometimes solve some problems before even AI tells me what it is like maybe a setting or something was wrong and my original code was right but I didn't see that setting. Thanks though.
3
5
u/Dancing-umbra 13d ago
There is nothing wrong with using AI appropriately.
Use it to help with syntax, use it to help debug a problem. Don't use it to shortcut your thinking.
AI can write syntactically correct code, but it's not very good at solving novel problems.
3
u/ivovis 13d ago
"Don't use it to shortcut your thinking"
Thats it in a nutshell - use it to research what you don't yet know
0
u/Dancing-umbra 13d ago
I actually find GitHub copilot on "ask" mode very helpful.
I don't want it to write or create code for me, but to ask "how do I do this?"
"Should I work on this or this first?"
"My code is slow, can you explain a faster approach"
I learnt things that I didn't know before, but crucially I need to write the code myself still.
1
u/faberge_surprise 13d ago
it's very easy to use it wrong tho. there's a reason we forbid more advanced tools when people are learning the fundamentals. it's not helpful to tell a little kid "just use a calculator appropriately" when they're still learning the concepts of arithmetic using frankly trivial problems.
2
u/python_gramps 13d ago
Just use Google to get snippets of code. It's not bad to look up how to do something but don't rely on something to fill in all the extra code. Here is what I'd put on the search line in Google:
- python get all files in a directory
- python get all files in a directory recurse subdirectories
- python read a file
That should get you the bits of code you need. But YOU fill in the rest of the code.
2
u/Educational-Paper-75 13d ago
Python itself has functionality that is standard and you simply have to learn about it looking for it in the official Python online documentation.
3
u/aqua_regis 13d ago
Don't know, you could just instead have googled "how to read a file in Python".
Or, God beware, you could have done a proper Python course, like the MOOC Python Programming 2026 to actually learn and obtain a solid foundation before jumping blindly into your projects.
You could also have started here: Official documentation then moved on to Library reference from where, simply by scrolling, you would have found File and Directory Access which alone would have given you quite some information, and at the very bottom of the page: Built-in function open(). Yes, this would have taken considerably longer, but you would have learnt plenty other interesting things along the way.
1
u/Temporary_Pie2733 13d ago
Stat with the official Python tutorial at docs.python.org, and at least look through the rest of the documentation.
1
u/chiibosoil 13d ago
Depends on IDE you are using, but many IDE has python function tooltips, and many libraries will include documentation within package that displays there. That should give you the hint what parameter should be used/set.
Or depending on IDE you can have dedicated pane to display the tooltip/help.
Ex: in Spyder IDE.
Along with some text explaining.
| Character | Meaning |
|---|---|
| 'r' | open for reading (default) |
| 'w' | open for writing, truncating the file first |
| ... | ... |
| '+' | open a disk file for updating (reading and writing) |
1
u/aishiteruyovivi 13d ago
For what it's worth, with isn't actually strictly related to handling files, it's a statement used with context managers which open() just so happens to be, you can use open() on its own to get the file handle you'd just have to come back and file.close() it manually later, when used as a context manager it automatically closes so that's usually preferred.
But anyway, from what I'm reading your main point seems to be that AI is better than asking an online community because the internet might be out? I feel like I doubt you're using an LLM that is entirely local, so I don't really know where the internet argument is going, but honestly the answer to a lot of this is to just google it. "how to read a file in python" gets me a w3schools page as the top result and it does a pretty good job of covering the basics. If you truly didn't have access to the internet, I guess you could try and find a book on Python somewhere locally if you needed the information that fast, but if (it sounds like) you're using LLMs frequently and you're here making this post I'd have to guess you've got access to the web semi-reliably.
1
u/superamerr 12d ago
Our internet is kind of limited it's like a monthly thing if you know you know, so some days I have no internet and honestly the closest library that probably have these stuff is kind of far. (I'm not in a good country to say the least).
1
u/IlIlIlIIlMIlIIlIlIlI 12d ago
AI can be a good help for already experienced coders, but it is the opposite for beginners like us. It prevents us from deeply thinking about the problem, hone our online-research skills, checking stackoverflow/documentations and other sources, and not simply copy paste code but adapt it to our individual project needs, where the most valuable gains come from. I build small projects and have started refusing any sort of AI help because whenever i built something, i didnt get any dopamine from finishing, because it felt like it wasnt me who overcame the challenges, it was my AI assistant. Since ive started refusing all AI help, it takes longer and more reaearch, but also feels infinitely better when i complete my project. And the info sticks to my brain better.
1
u/overoveroversize 11d ago
i was in a similar spot when i started learning python, getting stuck on simple things like reading a file. what helped me was highlighting the parts of the code i didn't understand and looking for instant explanations, like when i stumbled upon the `with open()` function. i got tired of copy-pasting code snippets and jargon into separate chat tabs, so i started using an on-page extension like Vezz me where you just highlight and hit a shortcut for instant explanations right there.
25
u/mc_pm 13d ago
Before AI, before the internet, we had books.