GetHacked
GetHacked

Reputation: 564

Where does a Python `schedule` scheduled task's return value go?

I have a scheduled task that runs using the schedule library. Where does the return value of my task go? Does returning True have a different effect than returning False?

Example:

def foo():
    return False

schedule.every().day.do(foo)
while True:
    schedule.run_pending()
    time.sleep(1)

Upvotes: 1

Views: 1155

Answers (1)

chepner
chepner

Reputation: 531225

It doesn't "go" anywhere. Every object has a reference count, and a call like

a = foo()

would simply increment the reference count of whatever object False refers to, to reflect that a is now also an reference to the same object.

In the absence of any such assignment, like with

foo()

the reference count simply is not incremented. If the only other reference to the value was a name local to foo, then the object would be subject to garbage collection.

Upvotes: 1

Related Questions