FIND YOUR NEXT FEW LINES

Results for “Errors & optional values”

Small, practical examples. Search by task or narrow things down below.

354 snippets foundClear filters
PythonFunctions & error handling

Avoid a shared mutable default argument

Python: Create a fresh list inside the function when the optional argument is omitted.

Python✓ Tested
SQLiteJSON data

Build a JSON array from rows

Aggregate ordered text values into JSON.

json_group_array✓ Tested
PythonText validation & encoding

Build a URL query string

Python: Use urlencode to percent-encode query parameter values correctly.

Python✓ Tested
PostgresWindows & text

Calculate a running total

Accumulate values in row order.

window✓ Tested
C#Dates & precise numbers

Calculate the number of calendar days between dates

C#: Subtract DayNumber values when the inputs are calendar dates.

C#✓ Tested
SQLiteDates & time

Calculate whole days between dates

Subtract Julian day values for date-only inputs.

julianday✓ Tested
PowerShellCommands & execution context

Capture a command’s success-stream output

PowerShell: Assignment collects output values without requiring text redirection to a file.

PowerShell✓ Tested
Arduino / CGetting Started

Change an LED delay with a variable

Arduino / C: Assign a new value to a variable to change the next LED pulse duration.

Arduino / C✓ Tested
PowerShellCommands & execution context

Check an external process exit status explicitly

PowerShell: LASTEXITCODE reports a native child exit code independently of ordinary PowerShell cmdlet errors.

PowerShell✓ Tested
C++Numeric parsing & calculations

Check an upper integer bound before adding

C++: For these nonnegative values, compare against the maximum minus the addend first.

C++✓ Tested
jQueryForm serialization & state

Collect repeated form field names

jQuery: serializeArray preserves multiple values as name-value records.

jQuery✓ Tested
SQLJoins & subqueries

Combine matching rows with INNER JOIN

Read product names with their matching stock values.

INNER JOIN✓ Tested