“Closed source” is a licensing term, not a human readability term . Technically, if I declare this code block:
to be released under a proprietary license, you would not be allowed to use that code without the risk of being sued for copyright infringement¹. If you want your code to be closed source, you just need to license it that way.
If you just don’t want people to be able to read your Python code, that’s an entirely different matter and not something that I support, so I’ll leave it to others to answer. But it’s not whether someone can read the code that makes it open source or not, it’s whether they’re allowed to use, modify, or redistribute the code (with or without changes), so making it unreadable just makes things harder for everybody involved and can be circumvented in various ways anyway.
¹I am not a lawyer and don’t even pretend to actually understand any of this from a legal perspective, this is all just my basic layman’s understanding. If you want anything remotely resembling legal advice, talk to a real lawyer