#🔒 question abt python files
44 messages · Page 1 of 1 (latest)
@fallow grotto
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
im new so can u explain this like im 5 years old
It's either configuration files or like
It's hard to explain specifically
In pynput, you will get errors when you use pyautogui to click right after pynput detects a click, it'll cause lag problems
To fix this, we will use statements and different files to stop the lag issue
That's my assumptions
I'm not sure what import is talking about, but the reason to have multiple python files in a project is more or less the same as the reason to have multiple c++ or java or c# files - easier to understand and maintain code, and modularity.
Modularity especially so, in Python.
Unlike java or c# that don't have top-level procedural code (everything is wrapped in a class or method), python modules are executed upon import
Tf🤣
I know It's terrible, but it was my assumption
what does pynput and pyautogui have to do
It was an example
This guy is right tho

For a more advanced example:
What's elegant in python is that you can swap module imports to achieve different functionality, like for example you could import database_mssql instead of database_mysql, assuming both implement a get_db function that your api endpoints depend on, and you will have swapped the database implementation, achieving the same level of modularity that you would achieve by implementing a repository pattern in something like c#, but in a more pythonic way.
Where the database_mssql and database_mysql modules include all the top-level code you need to build a connection string, engine, and whatever else you might need to connect to the database.
Then both modules contain the same function that just returns an instance of a database session / connection.
But yeah, maybe a too complex / convoluted example for your question - refer to my first answer.
If you're doing data science you can build pipelines from multiple modules in order to make your data flow easier to understand and reproduce.
You could of course technically do all this using one massive python file with thousands of lines, but why would you?
You guys aren't following the "explain like i'm 5 years old" prompt lol.
true, my bad
My version is "there's too much code. It could all be in one file, but it's better to group related code together in separate files"
Explain for a Galactic Emperor of Intergalactic Cyber Warfare and Quantum Encryption
with 2 bazillion years of experience
tbf 5 years old is quite young to even know what code is, so YMMV
they using scratch or sum shi
😂
As a dad of a 5 year old...yeah not even scratch
Damn🤣
I mean he's just learning to read so...
Yeah, start from the ground up haha
🤣 🤣 🤣
we'll build a CPU on a breadboard first though
then move up to machine instructions
@fallow grotto any more questions? Sorry going off on a tangent here...
chat gpt explains modularity for a 5 yr old: Oh boy, are you ready for a fun explanation?
Imagine you have a bunch of LEGO blocks in different shapes and colors. Each block can do a special thing, like one block can make a car move, another block can make a house appear, and another block can make a robot talk.
Modularity is like building with these LEGO blocks. Instead of trying to make one huge, complicated block that does everything, we break it down into smaller, simpler blocks that do one thing really well.
This way, when we want to build something new, like a castle, we can just take the blocks we need, like the house block and the car block, and connect them together to make something amazing!
And the best part? If we want to change something, like make the car block go faster, we can just take that one block out and replace it with a new one, without affecting the whole castle.
So, modularity is like building with LEGO blocks, where each block is a special piece that can be connected and used to make something new and amazing, and it makes it easy to change and improve things without making a big mess!
An introduction to assembler: where your preschooler's anger issues begin
Yeah...that's perfect.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.