tmp_file
result = tmp_file()
Input: no input · Output: result
What it is
Takes no arguments. Creates a new empty file under the OS temp directory with a name nothing else will collide with (process id, nanosecond clock, and a counter — any one alone has a plausible collision window).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = tmp_file() | no input | result Str | Returns a Str: its path, not an open handle, so it composes with fopen like any other path. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
path = tmp_file() # a scratch file, so this runs as written
write_text(path, "name,score\na,1\nb,4\nc,9\n")
txt = read_all_text(path)
print("chars: {len(txt)}")
output
chars: 23
from agent-guide
tmp_svg = tmp_file() + ".svg"
figure()
polygon([0.0, 1.0, 1.0], [0.0, 0.0, 1.0], fill = "#ff0000")
savefig(tmp_svg)
print(contains(read_all_text(tmp_svg), "opacity=\"0.18\"")) # true
output
· savefig <tmp>.svg
note: this figure uses screen styling and may not hold up in print -- call theme("publication") before saving for a paper (said once per session)
note: fonts render using whatever is installed on the viewer's machine (none are embedded) -- pass embed_fonts=true (fontfamily preset only) or export .tikz for guaranteed appearance
truefrom agent-guide