Skip to content

Commit

Permalink
[Stdlib] Add PythonObject.__contains__
Browse files Browse the repository at this point in the history
Signed-off-by: rd4com <[email protected]>
  • Loading branch information
rd4com committed Jun 22, 2024
1 parent 893920f commit 5a8c2ad
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions docs/manual/python/types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,13 @@
" var py_set = Python.evaluate('set([2, 3, 5, 7, 11])')\n",
" var num_items = len(py_set)\n",
" print(num_items, \" items in set.\") # prints \"5 items in set\"\n",
" print(py_set.__contains__(6)) # prints \"False\""
" print(6 in py_set) # prints \"False\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"TODO: You should be able to use the expression `6 in py_set`. However, because\n",
"of the way `PythonObject` currently works, you need to call the \n",
"`__contains__()` method directly.\n",
"\n",
"Some Mojo APIs handle `PythonObject` just fine, but sometimes you'll need to \n",
"explicitly convert a Python value into a native Mojo value. \n",
"\n",
Expand Down

0 comments on commit 5a8c2ad

Please sign in to comment.