#๐Ÿ”’ I'm beggining but i have a bit of a problem with understanding functions

27 messages ยท Page 1 of 1 (latest)

ionic sparrow
#

Hi, i'm trying to code some project for Uni (not that hard to do the italian way but i want to do it right in order to learn) but i can't understand how to communicate functions with functions:
Im using Tkinter to create a screen, then i want to create it in a function (sorta like a Main function), then separate the labels in another function, but how can i make the labels work outside of the Main function and alike? I don't know if i should use the parenthesis (and how) or to use XYZ.SOnlyToNotPutB

true doveBOT
#

@ionic sparrow

Python help channel opened

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.

ionic sparrow
#

it seems to have 3 ways of communicating outside functions return; function(whatyouwant) or func.whatyouwant

cerulean osprey
#

the separation you are trying to achieve can be done with classes

#

What is defined in a function can be sent out of it with return. function(...) is used to "send something" to a function, and func.whatyouwant is not a thing for regular functions

#

see functions as intermediary steps, taking an input and returning an output

#

if you want to separate the definitin of objects, like lables, windows, frames etc, you can use classes, or you can separate your project in multiple files an use imports

ionic sparrow
#

what are the dots used for then?

#

(i'm relly confused bcz my first time programming was a bit of gmmk and C++ for some weeks

#

)

cerulean osprey
#

accessible attributes and method

#

of class instances

cold shard
#

I think it's better to give an example of this, like, uh...

ionic sparrow
#

so its more so to communicate with imports and classes only?

cerulean osprey
#

functions do not "communicate"

#

they take an input, and turn it into an output

#

think of it like a blackbox. Whatever is inside, what interests you when using function is what it can return based on the input you give it

#

For example, str, int are funtions. You give them something, and they return the string or integer version of it

#

input is another function, which takes as input the prompt, and returns the user's input

#

print is a function a little bit different, as it doesn't have outputs. (however it has a "side effect" which is writing the input in the terminal)

cold shard
#

What was the original question, again?

#

How do you want the screen and labels to behave?

ionic sparrow
#

just text and GUI

#

dont worry, i understood it thanks

true doveBOT
#
Python help channel closed for inactivity

This help channel has been closed. 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.