From the documentation of completion-ignored-extensions
It ignores directory names if they match any string in this list which
ends in a slash.
so you can simply add __pycache__/ to the variable
Not too sure what the context of your question is. If you're using function read-file-name then you can pass it a PREDICATE argument that will exclude any files or dirs you want to exclude as completion candidates. C-h f read-file-name tells us:
Sixth arg PREDICATE, if non-nil, should be a function of one
argument; then a file name is considered an ...