Skip to content

Create sequences using initializer list #1669

@cowo78

Description

@cowo78

Issue description

To me it would be useful to be able to construct a few containers (i.e. tuple, list) using initializer lists. I would supply a patch.

Reproducible example code

Something like this:

pybind11::tuple create_tuple(std::initializer_list<pybind11::object> l)
{
    pybind11::tuple retval {l.size()};
    size_t index {0};
    for (const pybind11::object& item : l)
        retval[index++] = item;
    return retval;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions