Skip to content

Strange behavior with ternary operator #493

@sadseeker

Description

@sadseeker

I noticed strange behavior while trying to use ternary operator with boost::python::dict and list.
I'm trying to do something like this

using py = boost::python;

py::dict globals;
py::dict dict;
py::list list;
bool condition = true;
globals["mol"] = condition ? dict : list;
py::exec("print(type(mol))", globals);

What I expected: <class 'list'> or <class 'dict'>
What I got: <class 'Boost.Python.function'>

Is it expected behavior? Then can someone explain me why?
Or this is a bug?

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