> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python Positional-Only Parameter

Positional-only parameters are function parameters that must be supplied strictly based on their order in the function call, explicitly prohibiting the use of keyword arguments (e.g., `name=value`) for those specific parameters. Introduced in Python 3.8 (PEP 570), they are defined in a function signature using a forward slash (`/`).

All parameters declared before the `/` are enforced as positional-only. Parameters declared after the `/` retain standard Python behavior (they can be passed by position or by keyword) unless further modified by other signature operators.

## Syntax

```python theme={"dark"}
def function_name(pos_only_1, pos_only_2, /, standard_arg):
    pass
```

## Mechanics and Behavior

When a function is invoked, the Python interpreter maps the provided arguments to the signature. If an argument corresponding to a positional-only parameter is passed using keyword syntax, the interpreter raises a `TypeError`.

```python theme={"dark"}
def configure_matrix(rows, columns, /, fill_value):
    return [[fill_value] * columns for _ in range(rows)]


# VALID: 'rows' and 'columns' passed by position. 'fill_value' passed by position.
configure_matrix(3, 3, 0)


# VALID: 'rows' and 'columns' passed by position. 'fill_value' passed by keyword.
configure_matrix(3, 3, fill_value=0)


# INVALID: 'rows' and 'columns' passed by keyword.
configure_matrix(rows=3, columns=3, fill_value=0)

# TypeError: configure_matrix() got some positional-only arguments passed as keyword arguments: 'rows, columns'
```

## Signature Composition

The `/` operator can be combined with the `*` operator (which enforces keyword-only parameters) to create a strictly partitioned function signature. This establishes clear boundaries for argument resolution:

```python theme={"dark"}
def strict_function(pos_only, /, standard, *, kw_only):
    pass
```

1. **`pos_only`**: Must be passed by position.
2. **`/`**: Demarcates the end of positional-only parameters.
3. **`standard`**: Can be passed by position or keyword.
4. **`*`**: Demarcates the start of keyword-only parameters.
5. **`kw_only`**: Must be passed by keyword.

## Default Values

Positional-only parameters support default values. However, standard rules apply: a non-default positional-only parameter cannot follow a default positional-only parameter.

```python theme={"dark"}

# VALID
def parse_data(data, strict=True, /, encoding="utf-8"):
    pass


# INVALID: Non-default argument follows default argument
def parse_data(data=None, strict, /, encoding="utf-8"):
    pass
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Python Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
