#๐ What's wrong with the import Syntax?
29 messages ยท Page 1 of 1 (latest)
@velvet trail
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.
Already messed it up.
import hmd
I just want it to say program finished. Nothing else. But it says it can't find the module I made
from . import hmd and save the file to the same folder as the module
Oop
Ok, that worked, but now it is printing the hmd.py def functions. Is that supposed to happen, or do I do something about that?
@manic shore ?
that is not supposed to happen
what is in hmd.py?
def hmd(): print("Happy Mothers Day!") print("") print(" [][] [][]") print(" [][][][][][][]") print(" [][][][][][][]") print(" [][][][][]") print(" [][][]") print(" []") print("I'll make something for you! Food, Crafts, Whatever you want!") hmd()
Making something for my mom
is hmd something you created?
no worries, everybody started somewhere
Thanks for believing in me
I missed context so didn't realize you wrote hmd.py. There's also a Python module called hmd
!pip hmd
btw, if there's a module that runs something when run independently, and shouldn't when imported, there's a check for it
# functions and stuff for when the module is imported
if __name__ == "__main__":
# stuff that needs to run when the module is directly run
And that wasn't the problem. I had the function itself in the file.
Got it. Thanks for letting me know
You might find this interesting: https://realpython.com/python-application-layouts/
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.