class A:
def aaa(self):
return None
def aa():
a.aaa()
a = A()
print(aa())
a = A()
class A:
def aaa(self):
return None
def aa():
a.aaa()
print(aa())
When I use a function or class in Python, can I create a function even if the variable is not declared...? So it feels like you don't have to write a function or class at the top of the code in advance? I'm sorry. I was rambling. The above two codes work normally.
For example, the code below makes an error saying that the variable b has not been declared,,
class A:
def aaa(self):
return None
def aa():
b.aaa()
a = A()
print(aa())
I can't find any information about it even if I google it, so I'm posting a question.
python function variable
def aa(b):
b.aaa()
a = A()
print(aa(a))
© 2025 OneMinuteCode. All rights reserved.