Ask whether this function of python can be realized.

I want to have a function that is output when it is executed separately, but returns the output when called by other functions, but does not output
for example, code similar to the following when directly executed:
def foo:

print 111

but it is executed when called by another function:
def foo:

return 111

This is about the meaning of

. It is not very good at expressing it. To put it bluntly, it is an output function, but when called by other functions, it only returns the content of the calling function and does not output

.
Jun.23,2021

print foo ()


How can

be called by others?

class foo:
    def __str__(self):
        return 'print'

    def __call__(self, *args, **kwargs):
        print('111111')
a = foo()
a()
print(a)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eade81-2190.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eade81-2190.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?