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))
578 Understanding How to Configure Google API Key
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
581 PHP ssh2_scp_send fails to send files as intended
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.