py5_tools.live_coding.count()

py5_tools.live_coding.count()#

Return the number of times the live code has been updated.

Examples#

import py5_tools

count = py5_tools.live_coding.count()
py5_tools.live_coding.screenshot(f"version_{count}")
py5_tools.live_coding.copy_code(f"version_{count}")

Description#

Return the number of times the live code has been updated. This starts at zero and increments by one each time py5’s live coding system updates the code. If you exit a Sketch using py5’s live coding functionality and restart it, the counter resets to zero. The purpose of this function is to provide people using live coding with a value that changes from one code iteration to the next. This isn’t otherwise possible because the live coding feature will reset the global namespace each time the code is updated.

A good use case for this is to pair it with py5_tools.live_coding.screenshot() or py5_tools.live_coding.copy_code() to create a unique string to name the code backup copy or the screenshot. This is an alternative to timestamps.

This function will always return 0 when not running through py5’s live coding feature.

Look at the online “Live Coding” documentation to learn more.

Signatures#

count() -> int

Updated on September 15, 2024 12:12:36pm UTC