#๐ I want to store a functions end value without calling the function again.
28 messages ยท Page 1 of 1 (latest)
@wooden cliff
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.
I need to save the text value
without calling the trigger function in the person class
i tried to use different functions to save it and print it afterwards but
when i try to call the trigger function with the other objects, it prints out the same thing over and over
this is my output
It repets the first object that got his event when i try to trigger and print the other objects events
how can i fix this
I want to store a functions end value without calling the function again. (In a class)
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
Can you paste your code?
you should be doing self.event and self.active
and dont use globals. you dont need a text variable. you can just print(self.goodtext)
@wooden cliff
When adding functions or classes to a program, it can be tempting to reference inaccessible variables by declaring them as global. Doing this can result in code that is harder to read, debug and test. Instead of using globals, pass variables or objects as parameters and receive return values.
Instead of writing
def update_score():
global score, roll
score = score + roll
update_score()
do this instead
def update_score(score, roll):
return score + roll
score = update_score(score, roll)
For in-depth explanations on why global variables are bad news in a variety of situations, see this Stack Overflow answer.
do not use globals
im just trying to figure out this thing for 3 weeks, you saved me from my own hell
thank you
the solution was even easier, i dont understand how i never thinked this for 3 weeks
anyways ty again
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.
๐ I want to store a functions end value without calling the function again. (In a class)
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.