DVPPython Studio
Module 1: Direct the machine / Build 1 of 4

Preview consistent clip names

Return predictable filenames from new inputs, and reject names that could escape a folder.

This build previews one filename. Batch processing comes later; no files are renamed.

Runs on your computer · 35–50 minutes · no paid services

Download practice filesFiles, commands & notes

Without JavaScript, use the step links and keep your files on your computer.

One useful idea

A function is a small contract: inputs enter, a result comes back. return gives the caller a value; print only displays one. Separating these jobs lets the same naming rule work in a terminal, a batch tool or a test.

An f-string starts with f. Expressions inside braces are evaluated. In {version:02d}, d means decimal integer and 02 requests at least two digits, padded with zero. Version 100 stays 100; it is not shortened.

The reference validates first. safe_component strips outer whitespace, accepts 1–40 ASCII letters, digits, underscores or hyphens, and rejects reserved Windows names. It raises ValueError for a bad value and TypeError for a wrong type. This is deliberately narrower than every filename an operating system permits.

Refresh first: Values and strings, Functions and return.

Trace a finished example

from asset_tools import make_clip_name

name = make_clip_name("Harbour", "wide", 3)
print(name)
# Harbour_wide_v03.mp4

project becomes Harbour, shot becomes wide, and version becomes 3. Validation succeeds; interpolation combines the inputs; return sends the completed string back to name.

The finished implementation is in asset_tools.py. Reading it is guided practice, not independent evidence.

Predict before running

What does make_clip_name("Museum", "detail", 12) return?

Compare your answer · self-reviewed

Museum_detail_v12.mp4. The version is already two digits; the function must use the changed project and shot, not the example constants.

Explain the boundary

Why reject a shot named ../wide rather than just append .mp4?

Compare your answer · self-reviewed

A slash or dot sequence can represent navigation rather than a single filename component. Reject it at the naming boundary; do not silently change the request or modify a file.

Find the bug

A function prints the correct filename but has no return statement. What does the caller receive?

Compare your answer · self-reviewed

None. A test of the return value fails even if the terminal looks right. Return the filename; the CLI can print it later.

Try the idea in this browser

Runs in this browser · optional preparation · local project checks remain separate

Try a small function before opening your local files. Python downloads when you choose Run; if it cannot load, your code stays here and the local kit still works. The worker executes on your device, not on a DVP server. Only run code you trust: this is not a hostile-code security sandbox.

JavaScript loads the practice controls. Python starts only after Run.

Read the browser task briefs without running Python

Read a working naming function

Predict the two printed names, then Run. The checks call your function with additional projects, shots and versions. This browser task assumes project and shot are already safe text; complete component validation belongs to the separate local kit.

Reject invalid versions

Add validation before constructing the name: version must be int, not bool, and from 1 through 999. Raise TypeError for the wrong type and ValueError for the range. This does not replace local project/shot validation.

Build a naming rule from the brief

Write make_clip_name(project, shot, version) yourself. Return <project>_<shot>_v<version>.mp4, with a two-digit minimum version. Validate integer versions (not bool), from 1 through 999. Project and shot are assumed safe text for this browser subset. Try your own normal and refused inputs; printing a fixed example is not enough.

Change it, then build your own

One controlled change

Call the reference with Museum, detail and 12. Then try an empty project and a version of 0. Predict which call raises an error before you run it.

Your independent task

In practice.py, implement make_clip_name(project, shot, version). Import safe_component from asset_tools for the reviewed single-component policy, then validate version: an integer (not bool), from 1 through 999. Return the formatted name. Do not import the finished make_clip_name function.

What success looks like

Four naming test methods pass, including changed inputs, version 100, wrong types and unsafe names. The starter intentionally raises NotImplementedError until you implement it.

Hint 1 · a question

Which parts of the filename come from parameters? Write the expected result for version 3 and version 100.

Hint 2 · a concept cue

Validate components before constructing the result. Check the version type before comparing its range.

Hint 3 · a localized example

Use f"{project}_{shot}_v{version:02d}.mp4" after validation. This is formatting, not the complete solution.

Need the complete worked solution?

Open asset_tools.py from the kit. Trace it, close it, then try fresh inputs in your own files. Treat the attempt as guided; seeing the solution does not award a practical pass.

Course help is guidance, not independent evidence. With JavaScript, opening help records guidance locally; otherwise note it in your README. Reset does not erase that history.

Repair a failed check

If changed names fail, remove hardcoded Harbour/wide text. If True is accepted as a version, remember bool is a subclass of int: explicitly exclude it. If version 100 fails, use minimum-width formatting instead of taking the last two characters.

NotImplementedError means a practice stub is still unfinished. Read the failing test name and the last error line. Change one behavior, rerun that build, then rerun all implemented builds.

Show it works on new inputs

Use a different project and shot of your own, then version 1, 12 and 100. Record the returned names and one refused input. Explain why printing the example alone would not satisfy the contract.

Self-review: name the input, result, refused case and reason. Your local test output and explanation are separate from a quiz score; this page does not certify a pass.

Keep the idea

You separated a value-returning function from terminal output. Keep that boundary as the tool grows: validate inputs, return data, print at the edge.